@@ -10,7 +10,9 @@ import (
1010
1111 g "github.com/onsi/ginkgo/v2"
1212 o "github.com/onsi/gomega"
13+ configv1 "github.com/openshift/api/config/v1"
1314 opv1 "github.com/openshift/api/operator/v1"
15+ "github.com/openshift/library-go/pkg/config/clusteroperator/v1helpers"
1416 exutil "github.com/openshift/origin/test/extended/util"
1517 "gopkg.in/ini.v1"
1618 v1 "k8s.io/api/core/v1"
@@ -30,6 +32,37 @@ const (
3032 pollInterval = 5 * time .Second
3133)
3234
35+ // logOperatorStatus logs the current status of the storage operator for debugging
36+ func logOperatorStatus (ctx context.Context , oc * exutil.CLI ) {
37+ operator , err := oc .AdminConfigClient ().ConfigV1 ().ClusterOperators ().Get (ctx , "storage" , metav1.GetOptions {})
38+ if err != nil {
39+ e2e .Logf ("Failed to get storage operator status: %v" , err )
40+ return
41+ }
42+
43+ progressing := v1helpers .FindStatusCondition (operator .Status .Conditions , configv1 .OperatorProgressing )
44+ available := v1helpers .FindStatusCondition (operator .Status .Conditions , configv1 .OperatorAvailable )
45+ degraded := v1helpers .FindStatusCondition (operator .Status .Conditions , configv1 .OperatorDegraded )
46+
47+ progressingStatus := "Unknown"
48+ if progressing != nil {
49+ progressingStatus = fmt .Sprintf ("%s (Reason: %s, Message: %s)" , progressing .Status , progressing .Reason , progressing .Message )
50+ }
51+
52+ availableStatus := "Unknown"
53+ if available != nil {
54+ availableStatus = string (available .Status )
55+ }
56+
57+ degradedStatus := "Unknown"
58+ if degraded != nil {
59+ degradedStatus = string (degraded .Status )
60+ }
61+
62+ e2e .Logf ("Storage operator status - Progressing: %s, Available: %s, Degraded: %s" ,
63+ progressingStatus , availableStatus , degradedStatus )
64+ }
65+
3366// This is [Serial] because it modifies ClusterCSIDriver.
3467var _ = g .Describe ("[sig-storage][FeatureGate:VSphereDriverConfiguration][Serial][apigroup:operator.openshift.io] vSphere CSI Driver Configuration" , func () {
3568 defer g .GinkgoRecover ()
@@ -95,8 +128,9 @@ var _ = g.Describe("[sig-storage][FeatureGate:VSphereDriverConfiguration][Serial
95128 name string
96129 clusterCSIDriverOptions * opv1.VSphereCSIDriverConfigSpec
97130 cloudConfigOptions map [string ]string
98- successfulSnapshotsCreated int // Number of snapshots that should be created successfully, 0 to skip.
99- operatorShouldProgress bool // Indicates if we expect to see storage operator change condition to Progressing=True
131+ successfulSnapshotsCreated int // Number of snapshots that should be created successfully, 0 to skip.
132+ operatorShouldProgress bool // Indicates if we expect to see storage operator change condition to Progressing=True and back to False
133+ progressingTimeout time.Duration // Timeout for waiting for Progressing=True/False (defaults to 20s if not set)
100134 }{
101135 {
102136 name : "use default when unset" ,
@@ -164,27 +198,50 @@ var _ = g.Describe("[sig-storage][FeatureGate:VSphereDriverConfiguration][Serial
164198 setClusterCSIDriverSnapshotOptions (ctx , oc , t .clusterCSIDriverOptions )
165199
166200 if operatorShouldProgress {
167- // Wait for Progressing=True within 10 seconds
201+ timeout := t .progressingTimeout
202+ if timeout == 0 {
203+ timeout = 20 * time .Second
204+ }
205+
206+ e2e .Logf ("Waiting for storage operator to start progressing (Progressing=True) with timeout %v" , timeout )
207+ // Wait for Progressing=True
168208 {
169- ctxWithTimeout , cancel := context .WithTimeout (ctx , 10 * time . Second )
209+ ctxWithTimeout , cancel := context .WithTimeout (ctx , timeout )
170210 defer cancel ()
171211 err := exutil .WaitForOperatorProgressingTrue (ctxWithTimeout , oc .AdminConfigClient (), "storage" )
172- o .Expect (err ).NotTo (o .HaveOccurred ())
212+ if err != nil {
213+ logOperatorStatus (ctx , oc )
214+ o .Expect (err ).NotTo (o .HaveOccurred (), fmt .Sprintf ("Failed to wait for operator Progressing=True within %v" , timeout ))
215+ }
216+ e2e .Logf ("Storage operator is now Progressing=True" )
173217 }
174218
175- // Then wait for Progressing=False within next 10 seconds
219+ e2e .Logf ("Waiting for storage operator to stop progressing (Progressing=False) with timeout %v" , timeout )
220+ // Then wait for Progressing=False
176221 {
177- ctxWithTimeout , cancel := context .WithTimeout (ctx , 10 * time . Second )
222+ ctxWithTimeout , cancel := context .WithTimeout (ctx , timeout )
178223 defer cancel ()
224+ logOperatorStatus (ctx , oc )
225+
179226 err := exutil .WaitForOperatorProgressingFalse (ctxWithTimeout , oc .AdminConfigClient (), "storage" )
180- o .Expect (err ).NotTo (o .HaveOccurred ())
227+ if err != nil {
228+ e2e .Logf ("Timed out waiting for operator Progressing=False (timeout: %v)" , timeout )
229+ logOperatorStatus (ctx , oc )
230+ o .Expect (err ).NotTo (o .HaveOccurred (), fmt .Sprintf ("Failed to wait for operator Progressing=False within %v" , timeout ))
231+ } else {
232+ e2e .Logf ("Storage operator is now Progressing=False" )
233+ }
181234 }
182235 }
183236
237+ e2e .Logf ("Validating cloud.conf configuration matches expected snapshot options" )
184238 o .Eventually (func () error {
185239 return loadAndCheckCloudConf (ctx , oc , "Snapshot" , t .cloudConfigOptions , t .clusterCSIDriverOptions )
186240 }, pollTimeout , pollInterval ).Should (o .Succeed ())
187241
242+ if t .successfulSnapshotsCreated > 0 {
243+ e2e .Logf ("Validating snapshot creation (expecting %d successful snapshots)" , t .successfulSnapshotsCreated )
244+ }
188245 validateSnapshotCreation (ctx , oc , t .successfulSnapshotsCreated )
189246 })
190247 }
0 commit comments