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

modify error message when request volume is in use with other node #698

Merged

Conversation

AndyXiangLi
Copy link
Contributor

Is this a bug fix or adding new feature?
Fixes #515
What is this PR about? / Why do we need it?
According to https://github.com/container-storage-interface/spec/blob/master/spec.md#controllerpublishvolume-errors
We are returning wrong error code and error message when volume already assigned to different node
TODO: add logic to handle ALREADY_EXISTS scenario
What testing is done?
Sanity test passed
Added unit tests

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 14, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @AndyXiangLi. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 14, 2021
@coveralls
Copy link

coveralls commented Jan 14, 2021

Pull Request Test Coverage Report for Build 1561

  • 13 of 14 (92.86%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.09%) to 81.286%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/cloud/cloud.go 9 10 90.0%
Files with Coverage Reduction New Missed Lines %
pkg/driver/controller.go 1 90.49%
Totals Coverage Status
Change from base Build 1558: 0.09%
Covered Lines: 1707
Relevant Lines: 2100

💛 - Coveralls

@ayberk
Copy link
Contributor

ayberk commented Jan 15, 2021

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 15, 2021
@@ -115,6 +115,9 @@ var (
// ErrAlreadyExists is returned when a resource is already existent.
ErrAlreadyExists = errors.New("Resource already exists")

// ErrAlreadyExists is returned when a resource is already existent.
Copy link
Contributor

Choose a reason for hiding this comment

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

Hehe a copy-paste artifact here I see :)

@@ -115,6 +115,9 @@ var (
// ErrAlreadyExists is returned when a resource is already existent.
ErrAlreadyExists = errors.New("Resource already exists")
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 not use this anymore?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok I see the TODO below.


func getVolumeAttachmentsList(volume *ec2.Volume) []string {
var volumeAttachmentList []string
if len(volume.Attachments) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need this check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, we actually not need this.

if err == cloud.ErrAlreadyExists {
return nil, status.Error(codes.AlreadyExists, err.Error())
if err == cloud.ErrVolumeInUse {
return nil, status.Error(codes.FailedPrecondition, strings.Join(disk.Attachments, ","))
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is what we want. Looking at the API documentation[1][2], this list will have information about previous attachments as well, but the status will be "detached". So I think what we want to do is filter for "attached".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this is a good point, will update

@@ -2697,7 +2697,7 @@ func TestControllerPublishVolume(t *testing.T) {
if !ok {
t.Fatalf("Could not get error status code from error: %v", srvErr)
}
if srvErr.Code() != codes.AlreadyExists {
if srvErr.Code() != codes.FailedPrecondition {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also check if we're returning the correct instance id in the error message? It's a requirement from the spec.

func getVolumeAttachmentsList(volume *ec2.Volume) []string {
var volumeAttachmentList []string
for _, attachment := range volume.Attachments {
if attachment.State != nil && aws.StringValue(attachment.State) == "attached" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we lowercase aws.StringValue(attachment.State) just to be safe?

@ayberk
Copy link
Contributor

ayberk commented Feb 6, 2021

/approve
/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 6, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AndyXiangLi, ayberk

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 6, 2021
@k8s-ci-robot k8s-ci-robot merged commit 5af60ea into kubernetes-sigs:master Feb 6, 2021
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong Error Returned When Volume is Attached
4 participants