Skip to content

Commit ad35797

Browse files
committed
Retain volumesnapshot-being-created annotation until readyToUse=true
1 parent 7e30553 commit ad35797

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
@@ -394,12 +394,14 @@ func (ctrl *csiSnapshotSideCarController) createSnapshotWrapper(content *crdv1.V
394394
}
395395
content = newContent
396396

397-
// NOTE(xyang): handle create timeout
398-
// Remove annotation to indicate storage system has successfully
399-
// cut the snapshot
400-
content, err = ctrl.removeAnnVolumeSnapshotBeingCreated(content)
401-
if err != nil {
402-
return content, fmt.Errorf("failed to remove VolumeSnapshotBeingCreated annotation on the content %s: %q", content.Name, err)
397+
if contentIsReady(content) {
398+
// NOTE(xyang): handle create timeout
399+
// Remove annotation to indicate storage system has successfully
400+
// cut the snapshot
401+
content, err = ctrl.removeAnnVolumeSnapshotBeingCreated(content)
402+
if err != nil {
403+
return content, fmt.Errorf("failed to remove VolumeSnapshotBeingCreated annotation on the content %s: %q", content.Name, err)
404+
}
403405
}
404406

405407
return content, nil

0 commit comments

Comments
 (0)