Skip to content
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

Merged

Conversation

jsafrane
Copy link
Contributor

CSI wants CreateVolumeResponse.ContentSource to be set to the snapshot that has just been restored.

Fixes #444

CSI wants CreateVolumeResponse.ContentSource to be set to the snapshot that
has just been restored.
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 30, 2020
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jan 30, 2020
@coveralls
Copy link

coveralls commented Jan 30, 2020

Pull Request Test Coverage Report for Build 999

  • 24 of 28 (85.71%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.5%) to 71.421%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/driver/controller.go 22 26 84.62%
Totals Coverage Status
Change from base Build 996: 0.5%
Covered Lines: 1277
Relevant Lines: 1788

💛 - Coveralls

@jsafrane
Copy link
Contributor Author

jsafrane commented Feb 3, 2020

/assign @wongma7

@bertinatto
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 3, 2020
@@ -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
Copy link
Contributor

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

Copy link
Contributor Author

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.

// volume exists already
if disk != nil {
return newCreateVolumeResponse(disk), nil
return newCreateVolumeResponse(disk, snapshotID), nil
Copy link
Contributor

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

Copy link
Contributor Author

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

@leakingtapan
Copy link
Contributor

Could you add some unit test for it? thx

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 4, 2020
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 4, 2020
@jsafrane
Copy link
Contributor Author

jsafrane commented Feb 4, 2020

Could you add some unit test for it?

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.

@jsafrane
Copy link
Contributor Author

jsafrane commented Feb 4, 2020

VpcLimitExceeded: The maximum number of VPCs has been reached.
/retest

@leakingtapan
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 4, 2020
@k8s-ci-robot
Copy link
Contributor

[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:
  • OWNERS [jsafrane,leakingtapan]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit db95482 into kubernetes-sigs:master Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed to restore snapshot in 1.17
6 participants