mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-22 01:23:18 +00:00
Do not remove PVC ClaimRef to fix flaky VAC test
Signed-off-by: Connor Catlett <conncatl@amazon.com>
This commit is contained in:
@@ -328,7 +328,7 @@ func (v *volumeModifyTestSuite) DefineTests(driver storageframework.TestDriver,
|
||||
originPv := pv.DeepCopy()
|
||||
pv.Spec.PersistentVolumeReclaimPolicy = v1.PersistentVolumeReclaimRetain
|
||||
_, err = f.ClientSet.CoreV1().PersistentVolumes().Update(ctx, pv, metav1.UpdateOptions{})
|
||||
ginkgo.DeferCleanup(recoverPvReclaimPolicyAndRemoveClaimRef, f.ClientSet, originPv)
|
||||
ginkgo.DeferCleanup(recoverPvReclaimPolicy, f.ClientSet, originPv)
|
||||
framework.ExpectNoError(err, "Failed to update PV %q reclaim policy", pvName)
|
||||
|
||||
// The vac_protection_controller make sure there is a VolumeAttributesClass that is not used by any PVC/PV
|
||||
@@ -369,7 +369,7 @@ func (v *volumeModifyTestSuite) DefineTests(driver storageframework.TestDriver,
|
||||
|
||||
ginkgo.By(fmt.Sprintf("Deleting PV %q to make the vac unused for the PV", newVAC.Name))
|
||||
pv.Spec.PersistentVolumeReclaimPolicy = v1.PersistentVolumeReclaimDelete
|
||||
recoverPvReclaimPolicyAndRemoveClaimRef(ctx, f.ClientSet, pv)
|
||||
recoverPvReclaimPolicy(ctx, f.ClientSet, pv)
|
||||
|
||||
ginkgo.By(fmt.Sprintf("Waiting for PV %q to be deleted", pvName))
|
||||
gomega.Eventually(func() bool {
|
||||
@@ -432,8 +432,8 @@ func CleanupVAC(ctx context.Context, vac *storagev1beta1.VolumeAttributesClass,
|
||||
}, timeout, modifyPollInterval).Should(gomega.BeNil())
|
||||
}
|
||||
|
||||
// recoverPvReclaimPolicyAndRemoveClaimRef recovers the test pv's reclaim policy to expected used for clean up test PV
|
||||
func recoverPvReclaimPolicyAndRemoveClaimRef(ctx context.Context, c clientset.Interface, expectedPv *v1.PersistentVolume) {
|
||||
// recoverPvReclaimPolicy recovers the test pv's reclaim policy to expected used for clean up test PV
|
||||
func recoverPvReclaimPolicy(ctx context.Context, c clientset.Interface, expectedPv *v1.PersistentVolume) {
|
||||
setPvReclaimPolicyErr := retry.RetryOnConflict(retry.DefaultRetry, func() error {
|
||||
pv, err := c.CoreV1().PersistentVolumes().Get(ctx, expectedPv.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
@@ -443,11 +443,10 @@ func recoverPvReclaimPolicyAndRemoveClaimRef(ctx context.Context, c clientset.In
|
||||
}
|
||||
return err
|
||||
}
|
||||
if pv.Spec.PersistentVolumeReclaimPolicy == expectedPv.Spec.PersistentVolumeReclaimPolicy && pv.Spec.ClaimRef == nil {
|
||||
if pv.Spec.PersistentVolumeReclaimPolicy == expectedPv.Spec.PersistentVolumeReclaimPolicy {
|
||||
framework.Logf("PV %q reclaim policy is already recovered to %q", expectedPv.Name, expectedPv.Spec.PersistentVolumeReclaimPolicy)
|
||||
return nil
|
||||
}
|
||||
pv.Spec.ClaimRef = nil
|
||||
pv.Spec.PersistentVolumeReclaimPolicy = expectedPv.Spec.PersistentVolumeReclaimPolicy
|
||||
_, err = c.CoreV1().PersistentVolumes().Update(ctx, pv, metav1.UpdateOptions{})
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user