-
Notifications
You must be signed in to change notification settings - Fork 808
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
Fix CreateVolumeResponse after snapshot restore #446
Fix CreateVolumeResponse after snapshot restore #446
Conversation
CSI wants CreateVolumeResponse.ContentSource to be set to the snapshot that has just been restored.
Pull Request Test Coverage Report for Build 999
💛 - Coveralls |
/assign @wongma7 |
/lgtm |
pkg/driver/controller.go
Outdated
@@ -154,9 +154,14 @@ func (d *controllerService) CreateVolume(ctx context.Context, req *csi.CreateVol | |||
} | |||
} | |||
|
|||
snapshotID := "" | |||
if snapshotSource := req.VolumeContentSource.GetSnapshot(); snapshotSource != nil { | |||
snapshotID = snapshotSource.SnapshotId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to set the snapshot ID for an existing volume? Or only at line 188 here
https://github.com/kubernetes-sigs/aws-ebs-csi-driver/pull/446/files#diff-61566437d9b17d18936960aa0bce1ad4R187-R196
for restoring/creating the volume out of snapshot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, for idempotency. Responses to repeated CreateVolume requests for snapshot restore must have the same fields as the initial response.
pkg/driver/controller.go
Outdated
// volume exists already | ||
if disk != nil { | ||
return newCreateVolumeResponse(disk), nil | ||
return newCreateVolumeResponse(disk, snapshotID), nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer snapshot ID be part of the disk struct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added. But it moves us further away from #393
Could you add some unit test for it? thx |
And add unit tests
There were no snapshot restore tests. I added some. I added also a check if existing volume was created from expected snapshot, for repeated requests. |
|
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jsafrane, leakingtapan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
CSI wants CreateVolumeResponse.ContentSource to be set to the snapshot that has just been restored.
Fixes #444