diff --git a/pkg/sidecar-controller/content_create_test.go b/pkg/sidecar-controller/content_create_test.go index 0ba0ea529..ba61a80af 100644 --- a/pkg/sidecar-controller/content_create_test.go +++ b/pkg/sidecar-controller/content_create_test.go @@ -205,7 +205,7 @@ func TestSyncContent(t *testing.T) { nil), expectedContents: withContentAnnotations(withContentStatus(newContentArray("content1-7", "snapuid1-7", "snap1-7", "sid1-7", defaultClass, "", "volume-handle-1-7", retainPolicy, nil, &defaultSize, true), &crdv1.VolumeSnapshotContentStatus{SnapshotHandle: toStringPointer("snapuid1-7"), RestoreSize: &defaultSize, ReadyToUse: &False}), - map[string]string{}), + map[string]string{"snapshot.storage.kubernetes.io/volumesnapshot-being-created": "yes"}), expectedEvents: noevents, expectedCreateCalls: []createCall{ { @@ -236,7 +236,7 @@ func TestSyncContent(t *testing.T) { map[string]string{}), expectedContents: withContentAnnotations(withContentStatus(newContentArray("content1-8", "snapuid1-8", "snap1-8", "sid1-8", defaultClass, "", "volume-handle-1-8", retainPolicy, nil, &defaultSize, true), &crdv1.VolumeSnapshotContentStatus{SnapshotHandle: toStringPointer("snapuid1-8"), RestoreSize: &defaultSize, ReadyToUse: &False}), - map[string]string{}), + map[string]string{"snapshot.storage.kubernetes.io/volumesnapshot-being-created": "yes"}), expectedEvents: noevents, expectedCreateCalls: []createCall{ { diff --git a/pkg/sidecar-controller/snapshot_controller.go b/pkg/sidecar-controller/snapshot_controller.go index fbd4d9c28..180e9f5ba 100644 --- a/pkg/sidecar-controller/snapshot_controller.go +++ b/pkg/sidecar-controller/snapshot_controller.go @@ -394,12 +394,14 @@ func (ctrl *csiSnapshotSideCarController) createSnapshotWrapper(content *crdv1.V } content = newContent - // NOTE(xyang): handle create timeout - // Remove annotation to indicate storage system has successfully - // cut the snapshot - content, err = ctrl.removeAnnVolumeSnapshotBeingCreated(content) - if err != nil { - return content, fmt.Errorf("failed to remove VolumeSnapshotBeingCreated annotation on the content %s: %q", content.Name, err) + if contentIsReady(content) { + // NOTE(xyang): handle create timeout + // Remove annotation to indicate storage system has successfully + // cut the snapshot + content, err = ctrl.removeAnnVolumeSnapshotBeingCreated(content) + if err != nil { + return content, fmt.Errorf("failed to remove VolumeSnapshotBeingCreated annotation on the content %s: %q", content.Name, err) + } } return content, nil