diff --git a/pkg/kube/snapshot/snapshot.go b/pkg/kube/snapshot/snapshot.go index 0cf8654fe3..f489ca8662 100644 --- a/pkg/kube/snapshot/snapshot.go +++ b/pkg/kube/snapshot/snapshot.go @@ -169,7 +169,14 @@ func isTransientError(err error) bool { return transientErrorRegexp.MatchString(err.Error()) } -func waitOnReadyToUse(ctx context.Context, dynCli dynamic.Interface, snapGVR schema.GroupVersionResource, snapshotName, namespace string, isReadyFunc func(*unstructured.Unstructured) (bool, error)) error { +func waitOnReadyToUse( + ctx context.Context, + dynCli dynamic.Interface, + snapGVR schema.GroupVersionResource, + snapshotName, + namespace string, + isReadyFunc func(*unstructured.Unstructured) (bool, error), +) error { retries := 100 return poll.WaitWithRetries(ctx, retries, isTransientError, func(context.Context) (bool, error) { us, err := dynCli.Resource(snapGVR).Namespace(namespace).Get(ctx, snapshotName, metav1.GetOptions{}) diff --git a/pkg/kube/snapshot/snapshot_alpha.go b/pkg/kube/snapshot/snapshot_alpha.go index da76389c77..e1bc3c70e2 100644 --- a/pkg/kube/snapshot/snapshot_alpha.go +++ b/pkg/kube/snapshot/snapshot_alpha.go @@ -331,7 +331,6 @@ func isReadyToUseAlpha(us *unstructured.Unstructured) (bool, error) { // WaitOnReadyToUse will block until the Volumesnapshot in namespace 'namespace' with name 'snapshotName' // has status 'ReadyToUse' or 'ctx.Done()' is signalled. -// FIXME: merge this with beta wait func (sna *SnapshotAlpha) WaitOnReadyToUse(ctx context.Context, snapshotName, namespace string) error { return waitOnReadyToUse(ctx, sna.dynCli, v1alpha1.VolSnapGVR, snapshotName, namespace, isReadyToUseAlpha) } diff --git a/pkg/kube/snapshot/snapshot_test.go b/pkg/kube/snapshot/snapshot_test.go index 4a9949e02b..de95276e9b 100644 --- a/pkg/kube/snapshot/snapshot_test.go +++ b/pkg/kube/snapshot/snapshot_test.go @@ -365,7 +365,7 @@ func (s *SnapshotTestSuite) TestVolumeSnapshotCloneFake(c *C) { } func (s *SnapshotTestSuite) TestWaitOnReadyToUse(c *C) { - snapshotName := "snap-1-fake" + snapshotNameBase := "snap-1-fake" volName := "pvc-1-fake" scheme := runtime.NewScheme() scheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "snapshot.storage.k8s.io", Version: "v1alpha1", Kind: "VolumeSnapshotClassList"}, &unstructured.UnstructuredList{}) @@ -402,16 +402,17 @@ func (s *SnapshotTestSuite) TestWaitOnReadyToUse(c *C) { ctx := context.Background() var volumeSnapshotGVR schema.GroupVersionResource + var snapshotName string switch fakeSs.(type) { case *snapshot.SnapshotAlpha: volumeSnapshotGVR = v1alpha1.VolSnapGVR - snapshotName = snapshotName + "-alpha" + snapshotName = snapshotNameBase + "-alpha" case *snapshot.SnapshotBeta: volumeSnapshotGVR = v1beta1.VolSnapGVR - snapshotName = snapshotName + "-beta" + snapshotName = snapshotNameBase + "-beta" case *snapshot.SnapshotStable: volumeSnapshotGVR = snapshot.VolSnapGVR - snapshotName = snapshotName + "-stable" + snapshotName = snapshotNameBase + "-stable" } err = fakeSs.Create(ctx, snapshotName, defaultNamespace, volName, &fakeClass, false, nil)