Skip to content

Commit 04ad286

Browse files
committed
Retain volumesnapshot-being-created annotation until readyToUse=true
1 parent 59d7297 commit 04ad286

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

pkg/sidecar-controller/content_create_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func TestSyncContent(t *testing.T) {
205205
nil),
206206
expectedContents: withContentAnnotations(withContentStatus(newContentArray("content1-7", "snapuid1-7", "snap1-7", "sid1-7", defaultClass, "", "volume-handle-1-7", retainPolicy, nil, &defaultSize, true),
207207
&crdv1.VolumeSnapshotContentStatus{SnapshotHandle: toStringPointer("snapuid1-7"), RestoreSize: &defaultSize, ReadyToUse: &False}),
208-
map[string]string{}),
208+
map[string]string{"snapshot.storage.kubernetes.io/volumesnapshot-being-created": "yes"}),
209209
expectedEvents: noevents,
210210
expectedCreateCalls: []createCall{
211211
{
@@ -236,7 +236,7 @@ func TestSyncContent(t *testing.T) {
236236
map[string]string{}),
237237
expectedContents: withContentAnnotations(withContentStatus(newContentArray("content1-8", "snapuid1-8", "snap1-8", "sid1-8", defaultClass, "", "volume-handle-1-8", retainPolicy, nil, &defaultSize, true),
238238
&crdv1.VolumeSnapshotContentStatus{SnapshotHandle: toStringPointer("snapuid1-8"), RestoreSize: &defaultSize, ReadyToUse: &False}),
239-
map[string]string{}),
239+
map[string]string{"snapshot.storage.kubernetes.io/volumesnapshot-being-created": "yes"}),
240240
expectedEvents: noevents,
241241
expectedCreateCalls: []createCall{
242242
{

pkg/sidecar-controller/snapshot_controller.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,12 +385,14 @@ func (ctrl *csiSnapshotSideCarController) createSnapshotWrapper(content *crdv1.V
385385
}
386386
content = newContent
387387

388-
// NOTE(xyang): handle create timeout
389-
// Remove annotation to indicate storage system has successfully
390-
// cut the snapshot
391-
content, err = ctrl.removeAnnVolumeSnapshotBeingCreated(content)
392-
if err != nil {
393-
return content, fmt.Errorf("failed to remove VolumeSnapshotBeingCreated annotation on the content %s: %q", content.Name, err)
388+
if contentIsReady(content) {
389+
// NOTE(xyang): handle create timeout
390+
// Remove annotation to indicate storage system has successfully
391+
// cut the snapshot
392+
content, err = ctrl.removeAnnVolumeSnapshotBeingCreated(content)
393+
if err != nil {
394+
return content, fmt.Errorf("failed to remove VolumeSnapshotBeingCreated annotation on the content %s: %q", content.Name, err)
395+
}
394396
}
395397

396398
return content, nil

0 commit comments

Comments
 (0)