@@ -591,33 +591,36 @@ var _ = utils.SIGDescribe("CSI Mock volume expansion", func() {
591591
592592func validateQuotaUsage (ctx context.Context , m * mockDriverSetup , currentQuota , expectedQuota * v1.ResourceQuota ) {
593593 ginkgo .By ("Waiting for resource quota usage to be updated" )
594- var err error
595- var quota * v1.ResourceQuota
596- var usedCount resource.Quantity
597- var usedSize resource.Quantity
594+ var (
595+ quota * v1.ResourceQuota
596+ usedCount resource.Quantity
597+ usedSize resource.Quantity
598+ )
598599
599600 expectedCount := expectedQuota .Status .Used [pvcCountQuotaKey ]
600601 expectedUsedSize := expectedQuota .Status .Used [pvcSizeQuotaKey ]
601602
602- waitErr := wait . PollUntilContextTimeout ( ctx , resizePollInterval , csiResizeWaitPeriod , true , func (pollContext context. Context ) ( bool , error ) {
603- quota , err = m .cs .CoreV1 ().ResourceQuotas (currentQuota .Namespace ).Get (pollContext , currentQuota .Name , metav1.GetOptions {})
603+ gomega . Eventually ( func () error {
604+ q , err : = m .cs .CoreV1 ().ResourceQuotas (currentQuota .Namespace ).Get (ctx , currentQuota .Name , metav1.GetOptions {})
604605 if err != nil {
605- return false , fmt .Errorf ("error fetching resource quota %q : %w" , expectedQuota .Name , err )
606+ return fmt .Errorf ("failed to get resource quota %s/%s : %w" , currentQuota . Namespace , currentQuota .Name , err )
606607 }
607- if quota .Status .Used == nil {
608- return false , nil
608+ if q .Status .Used == nil {
609+ return fmt . Errorf ( "resource quota %s/%s has nil Status.Used" , currentQuota . Namespace , currentQuota . Name )
609610 }
611+
612+ quota = q
610613 usedCount = quota .Status .Used [pvcCountQuotaKey ]
611614 usedSize = quota .Status .Used [pvcSizeQuotaKey ]
612- if usedCount .Cmp (expectedCount ) == 0 && usedSize .Cmp (expectedUsedSize ) == 0 {
613- return true , nil
614- }
615- return false , nil
616- })
617615
618- if waitErr != nil {
619- framework .Failf ("error while waiting for resource quota usage to be updated, currentlyUsed: %s/%s, expected: %s/%s: %v" , usedCount .String (), usedSize .String (), expectedCount .String (), expectedUsedSize .String (), waitErr )
620- }
616+ if usedCount .Cmp (expectedCount ) != 0 || usedSize .Cmp (expectedUsedSize ) != 0 {
617+ return fmt .Errorf (
618+ "resource quota usage did not converge; currentlyUsed: %s/%s, expected: %s/%s" ,
619+ usedCount .String (), usedSize .String (), expectedCount .String (), expectedUsedSize .String (),
620+ )
621+ }
622+ return nil
623+ }, csiResizeWaitPeriod , resizePollInterval ).Should (gomega .Succeed ())
621624}
622625
623626func validateRecoveryBehaviour (ctx context.Context , pvc * v1.PersistentVolumeClaim , m * mockDriverSetup , test recoveryTest ) {
@@ -647,8 +650,10 @@ func validateRecoveryBehaviour(ctx context.Context, pvc *v1.PersistentVolumeClai
647650 framework .Failf ("error updating pvc size %q" , pvc .Name )
648651 }
649652
650- // if expansion failed on controller with final error, then recovery should be possible
651- if test .simulatedCSIDriverError == expansionFailedOnControllerWithInfeasibleError {
653+ // If expansion failed on controller (infeasible or final), recovery should be possible.
654+ // Wait for the recovery resize to settle before checking quota.
655+ if test .simulatedCSIDriverError == expansionFailedOnControllerWithInfeasibleError ||
656+ test .simulatedCSIDriverError == expansionFailedOnControllerWithFinalError {
652657 validateExpansionSuccess (ctx , pvc , m , test , test .recoverySize .String ())
653658 return
654659 }
0 commit comments