Skip to content

Commit d78137b

Browse files
committed
Fix PVC condition check for offline resizing
1 parent 77e110f commit d78137b

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

test/e2e/storage/testsuites/volume_expand.go

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ const (
4040
resizePollInterval = 2 * time.Second
4141
// total time to wait for cloudprovider or file system resize to finish
4242
totalResizeWaitPeriod = 10 * time.Minute
43+
// time to wait for PVC conditions to sync
44+
pvcConditionSyncPeriod = 2 * time.Minute
4345
)
4446

4547
type volumeExpandTestSuite struct {
@@ -194,15 +196,9 @@ func (v *volumeExpandTestSuite) defineTests(driver TestDriver, pattern testpatte
194196
framework.ExpectNoError(err, "While waiting for pvc resize to finish")
195197

196198
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
206202

207203
ginkgo.By("Creating a new pod with same volume")
208204
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
329325
})
330326
}
331327

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+
332353
// WaitForFSResize waits for the filesystem in the pv to be resized
333354
func WaitForFSResize(pvc *v1.PersistentVolumeClaim, c clientset.Interface) (*v1.PersistentVolumeClaim, error) {
334355
var updatedPVC *v1.PersistentVolumeClaim

0 commit comments

Comments
 (0)