@@ -40,6 +40,8 @@ const (
40
40
resizePollInterval = 2 * time .Second
41
41
// total time to wait for cloudprovider or file system resize to finish
42
42
totalResizeWaitPeriod = 10 * time .Minute
43
+ // time to wait for PVC conditions to sync
44
+ pvcConditionSyncPeriod = 2 * time .Minute
43
45
)
44
46
45
47
type volumeExpandTestSuite struct {
@@ -194,15 +196,9 @@ func (v *volumeExpandTestSuite) defineTests(driver TestDriver, pattern testpatte
194
196
framework .ExpectNoError (err , "While waiting for pvc resize to finish" )
195
197
196
198
ginkgo .By ("Checking for conditions on pvc" )
197
- l .resource .pvc , err = f .ClientSet .CoreV1 ().PersistentVolumeClaims (f .Namespace .Name ).Get (l .resource .pvc .Name , metav1.GetOptions {})
198
- framework .ExpectNoError (err , "While fetching pvc after controller resize" )
199
-
200
- inProgressConditions := l .resource .pvc .Status .Conditions
201
- // if there are conditions on the PVC, it must be of FileSystemResizePending type
202
- if len (inProgressConditions ) > 0 {
203
- framework .ExpectEqual (len (inProgressConditions ), 1 , "pvc must have file system resize pending condition" )
204
- framework .ExpectEqual (inProgressConditions [0 ].Type , v1 .PersistentVolumeClaimFileSystemResizePending , "pvc must have fs resizing condition" )
205
- }
199
+ npvc , err := WaitForPendingFSResizeCondition (l .resource .pvc , f .ClientSet )
200
+ framework .ExpectNoError (err , "While waiting for pvc to have fs resizing condition" )
201
+ l .resource .pvc = npvc
206
202
207
203
ginkgo .By ("Creating a new pod with same volume" )
208
204
l .pod2 , err = e2epod .CreateSecPodWithNodeSelection (f .ClientSet , f .Namespace .Name , []* v1.PersistentVolumeClaim {l .resource .pvc }, nil , false , "" , false , false , e2epv .SELinuxLabel , nil , e2epod.NodeSelection {Name : l .config .ClientNodeName }, framework .PodStartTimeout )
@@ -329,6 +325,31 @@ func WaitForControllerVolumeResize(pvc *v1.PersistentVolumeClaim, c clientset.In
329
325
})
330
326
}
331
327
328
+ // WaitForPendingFSResizeCondition waits for pvc to have resize condition
329
+ func WaitForPendingFSResizeCondition (pvc * v1.PersistentVolumeClaim , c clientset.Interface ) (* v1.PersistentVolumeClaim , error ) {
330
+ var updatedPVC * v1.PersistentVolumeClaim
331
+ waitErr := wait .PollImmediate (resizePollInterval , pvcConditionSyncPeriod , func () (bool , error ) {
332
+ var err error
333
+ updatedPVC , err = c .CoreV1 ().PersistentVolumeClaims (pvc .Namespace ).Get (pvc .Name , metav1.GetOptions {})
334
+
335
+ if err != nil {
336
+ return false , fmt .Errorf ("error fetching pvc %q for checking for resize status : %v" , pvc .Name , err )
337
+ }
338
+
339
+ inProgressConditions := updatedPVC .Status .Conditions
340
+ // if there are no PVC conditions that means no node expansion is necessary
341
+ if len (inProgressConditions ) == 0 {
342
+ return true , nil
343
+ }
344
+ conditionType := inProgressConditions [0 ].Type
345
+ if conditionType == v1 .PersistentVolumeClaimFileSystemResizePending {
346
+ return true , nil
347
+ }
348
+ return false , nil
349
+ })
350
+ return updatedPVC , waitErr
351
+ }
352
+
332
353
// WaitForFSResize waits for the filesystem in the pv to be resized
333
354
func WaitForFSResize (pvc * v1.PersistentVolumeClaim , c clientset.Interface ) (* v1.PersistentVolumeClaim , error ) {
334
355
var updatedPVC * v1.PersistentVolumeClaim
0 commit comments