Skip to content

Retain volumesnapshot-being-created annotation until readyToUse=true #1283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/sidecar-controller/content_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
{
Expand Down Expand Up @@ -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{
{
Expand Down
14 changes: 8 additions & 6 deletions pkg/sidecar-controller/snapshot_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As described in the comments, the annotation is only needed before the snapshot is cut on the storage system. After the snapshot is cut, a snapshot id will be returned and can be used to identify the snapshot on the storage system (if user chooses to delete the snapshot).
I don't see why we have to wait until the snapshot is post processed and ready to use set to true.

// 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
Expand Down
Loading