mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Return new PVC in WaitForVolumeModification to prevent stale comparison
Signed-off-by: Connor Catlett <conncatl@amazon.com>
This commit is contained in:
parent
d21b17264e
commit
796ae44c08
@ -188,12 +188,11 @@ func (v *volumeModifyTestSuite) DefineTests(driver storageframework.TestDriver,
|
|||||||
framework.ExpectNoError(err, "While creating pod for modifying")
|
framework.ExpectNoError(err, "While creating pod for modifying")
|
||||||
|
|
||||||
ginkgo.By("Modifying PVC via VAC")
|
ginkgo.By("Modifying PVC via VAC")
|
||||||
newPVC := SetPVCVACName(ctx, l.resource.Pvc, l.vac.Name, f.ClientSet, setVACWaitPeriod)
|
l.resource.Pvc = SetPVCVACName(ctx, l.resource.Pvc, l.vac.Name, f.ClientSet, setVACWaitPeriod)
|
||||||
l.resource.Pvc = newPVC
|
|
||||||
gomega.Expect(l.resource.Pvc).NotTo(gomega.BeNil())
|
gomega.Expect(l.resource.Pvc).NotTo(gomega.BeNil())
|
||||||
|
|
||||||
ginkgo.By("Waiting for modification to finish")
|
ginkgo.By("Waiting for modification to finish")
|
||||||
WaitForVolumeModification(ctx, l.resource.Pvc, f.ClientSet, modifyVolumeWaitPeriod)
|
l.resource.Pvc = WaitForVolumeModification(ctx, l.resource.Pvc, f.ClientSet, modifyVolumeWaitPeriod)
|
||||||
|
|
||||||
pvcConditions := l.resource.Pvc.Status.Conditions
|
pvcConditions := l.resource.Pvc.Status.Conditions
|
||||||
gomega.Expect(pvcConditions).To(gomega.BeEmpty(), "PVC should not have conditions")
|
gomega.Expect(pvcConditions).To(gomega.BeEmpty(), "PVC should not have conditions")
|
||||||
@ -223,12 +222,11 @@ func (v *volumeModifyTestSuite) DefineTests(driver storageframework.TestDriver,
|
|||||||
framework.ExpectNoError(err, "While creating pod for modifying")
|
framework.ExpectNoError(err, "While creating pod for modifying")
|
||||||
|
|
||||||
ginkgo.By("Modifying PVC via VAC")
|
ginkgo.By("Modifying PVC via VAC")
|
||||||
newPVC := SetPVCVACName(ctx, l.resource.Pvc, newVAC.Name, f.ClientSet, setVACWaitPeriod)
|
l.resource.Pvc = SetPVCVACName(ctx, l.resource.Pvc, newVAC.Name, f.ClientSet, setVACWaitPeriod)
|
||||||
l.resource.Pvc = newPVC
|
|
||||||
gomega.Expect(l.resource.Pvc).NotTo(gomega.BeNil())
|
gomega.Expect(l.resource.Pvc).NotTo(gomega.BeNil())
|
||||||
|
|
||||||
ginkgo.By("Waiting for modification to finish")
|
ginkgo.By("Waiting for modification to finish")
|
||||||
WaitForVolumeModification(ctx, l.resource.Pvc, f.ClientSet, modifyVolumeWaitPeriod)
|
l.resource.Pvc = WaitForVolumeModification(ctx, l.resource.Pvc, f.ClientSet, modifyVolumeWaitPeriod)
|
||||||
|
|
||||||
pvcConditions := l.resource.Pvc.Status.Conditions
|
pvcConditions := l.resource.Pvc.Status.Conditions
|
||||||
gomega.Expect(pvcConditions).To(gomega.BeEmpty(), "PVC should not have conditions")
|
gomega.Expect(pvcConditions).To(gomega.BeEmpty(), "PVC should not have conditions")
|
||||||
@ -254,16 +252,18 @@ func SetPVCVACName(ctx context.Context, origPVC *v1.PersistentVolumeClaim, name
|
|||||||
|
|
||||||
// WaitForVolumeModification waits for the volume to be modified
|
// WaitForVolumeModification waits for the volume to be modified
|
||||||
// The input PVC is assumed to have a VolumeAttributesClassName set
|
// The input PVC is assumed to have a VolumeAttributesClassName set
|
||||||
func WaitForVolumeModification(ctx context.Context, pvc *v1.PersistentVolumeClaim, c clientset.Interface, timeout time.Duration) {
|
func WaitForVolumeModification(ctx context.Context, pvc *v1.PersistentVolumeClaim, c clientset.Interface, timeout time.Duration) *v1.PersistentVolumeClaim {
|
||||||
|
var newPVC *v1.PersistentVolumeClaim
|
||||||
pvName := pvc.Spec.VolumeName
|
pvName := pvc.Spec.VolumeName
|
||||||
gomega.Eventually(ctx, func(g gomega.Gomega) {
|
gomega.Eventually(ctx, func(g gomega.Gomega) {
|
||||||
pv, err := c.CoreV1().PersistentVolumes().Get(ctx, pvName, metav1.GetOptions{})
|
pv, err := c.CoreV1().PersistentVolumes().Get(ctx, pvName, metav1.GetOptions{})
|
||||||
framework.ExpectNoError(err, "While getting existing PV")
|
framework.ExpectNoError(err, "While getting existing PV")
|
||||||
g.Expect(pv.Spec.VolumeAttributesClassName).NotTo(gomega.BeNil())
|
g.Expect(pv.Spec.VolumeAttributesClassName).NotTo(gomega.BeNil())
|
||||||
newPVC, err := c.CoreV1().PersistentVolumeClaims(pvc.Namespace).Get(ctx, pvc.Name, metav1.GetOptions{})
|
newPVC, err = c.CoreV1().PersistentVolumeClaims(pvc.Namespace).Get(ctx, pvc.Name, metav1.GetOptions{})
|
||||||
framework.ExpectNoError(err, "While getting new PVC")
|
framework.ExpectNoError(err, "While getting new PVC")
|
||||||
g.Expect(vacMatches(newPVC, *pv.Spec.VolumeAttributesClassName, true)).To(gomega.BeTrueBecause("Modified PVC should match expected VAC"))
|
g.Expect(vacMatches(newPVC, *pv.Spec.VolumeAttributesClassName, true)).To(gomega.BeTrueBecause("Modified PVC should match expected VAC"))
|
||||||
}, timeout, modifyPollInterval).Should(gomega.Succeed())
|
}, timeout, modifyPollInterval).Should(gomega.Succeed())
|
||||||
|
return newPVC
|
||||||
}
|
}
|
||||||
|
|
||||||
func CleanupVAC(ctx context.Context, vac *storagev1alpha1.VolumeAttributesClass, c clientset.Interface, timeout time.Duration) {
|
func CleanupVAC(ctx context.Context, vac *storagev1alpha1.VolumeAttributesClass, c clientset.Interface, timeout time.Duration) {
|
||||||
|
Loading…
Reference in New Issue
Block a user