mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 10:20:51 +00:00
Fix storage e2e snapshot test deletion order
This commit is contained in:
parent
2a05c78600
commit
c4dfee6262
@ -1303,7 +1303,7 @@ var _ = utils.SIGDescribe("CSI mock volume", func() {
|
|||||||
framework.Logf("PVC not found. Continuing to test VolumeSnapshotContent finalizer")
|
framework.Logf("PVC not found. Continuing to test VolumeSnapshotContent finalizer")
|
||||||
}
|
}
|
||||||
if claim != nil && claim.DeletionTimestamp == nil {
|
if claim != nil && claim.DeletionTimestamp == nil {
|
||||||
framework.Failf("Expected deletion timestamp to be set on PVC %s", claim.Name)
|
framework.Failf("Expected deletion timestamp to be set on PVC: %v", claim)
|
||||||
}
|
}
|
||||||
|
|
||||||
ginkgo.By(fmt.Sprintf("Get VolumeSnapshotContent bound to VolumeSnapshot %s", snapshot.GetName()))
|
ginkgo.By(fmt.Sprintf("Get VolumeSnapshotContent bound to VolumeSnapshot %s", snapshot.GetName()))
|
||||||
|
@ -269,8 +269,17 @@ func (s *snapshottableTestSuite) DefineTests(driver storageframework.TestDriver,
|
|||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
ginkgo.By("should delete the VolumeSnapshotContent according to its deletion policy")
|
ginkgo.By("should delete the VolumeSnapshotContent according to its deletion policy")
|
||||||
err = storageutils.DeleteAndWaitSnapshot(dc, vs.GetNamespace(), vs.GetName(), framework.Poll, f.Timeouts.SnapshotDelete)
|
|
||||||
|
// Delete both Snapshot and PVC at the same time because different storage systems
|
||||||
|
// have different ordering of deletion. Some may require delete PVC first before
|
||||||
|
// Snapshot deletion and some are opposite.
|
||||||
|
err = storageutils.DeleteSnapshotWithoutWaiting(dc, vs.GetNamespace(), vs.GetName())
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
err = cs.CoreV1().PersistentVolumeClaims(restoredPVC.Namespace).Delete(context.TODO(), restoredPVC.Name, metav1.DeleteOptions{})
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
|
// Wait for the Snapshot to be actually deleted from API server
|
||||||
|
err = storageutils.WaitForNamespacedGVRDeletion(dc, storageutils.SnapshotGVR, vs.GetNamespace(), vs.GetNamespace(), framework.Poll, f.Timeouts.SnapshotDelete)
|
||||||
|
|
||||||
switch pattern.SnapshotDeletionPolicy {
|
switch pattern.SnapshotDeletionPolicy {
|
||||||
case storageframework.DeleteSnapshot:
|
case storageframework.DeleteSnapshot:
|
||||||
|
@ -100,12 +100,21 @@ func GetSnapshotContentFromSnapshot(dc dynamic.Interface, snapshot *unstructured
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeleteSnapshotWithoutWaiting deletes a VolumeSnapshot and return directly without waiting
|
||||||
|
func DeleteSnapshotWithoutWaiting(dc dynamic.Interface, ns string, snapshotName string) error {
|
||||||
|
ginkgo.By("deleting the snapshot")
|
||||||
|
err := dc.Resource(SnapshotGVR).Namespace(ns).Delete(context.TODO(), snapshotName, metav1.DeleteOptions{})
|
||||||
|
if err != nil && !apierrors.IsNotFound(err) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// DeleteAndWaitSnapshot deletes a VolumeSnapshot and waits for it to be deleted or until timeout occurs, whichever comes first
|
// DeleteAndWaitSnapshot deletes a VolumeSnapshot and waits for it to be deleted or until timeout occurs, whichever comes first
|
||||||
func DeleteAndWaitSnapshot(dc dynamic.Interface, ns string, snapshotName string, poll, timeout time.Duration) error {
|
func DeleteAndWaitSnapshot(dc dynamic.Interface, ns string, snapshotName string, poll, timeout time.Duration) error {
|
||||||
var err error
|
var err error
|
||||||
ginkgo.By("deleting the snapshot")
|
err = DeleteSnapshotWithoutWaiting(dc, ns, snapshotName)
|
||||||
err = dc.Resource(SnapshotGVR).Namespace(ns).Delete(context.TODO(), snapshotName, metav1.DeleteOptions{})
|
if err != nil {
|
||||||
if err != nil && !apierrors.IsNotFound(err) {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user