-
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
modify error message when request volume is in use with other node #698
modify error message when request volume is in use with other node #698
Conversation
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 Once the patch is verified, the new status will be reflected by the 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. |
Pull Request Test Coverage Report for Build 1561
💛 - Coveralls |
/ok-to-test |
pkg/cloud/cloud.go
Outdated
@@ -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. |
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.
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") |
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 not use this anymore?
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.
Ok I see the TODO below.
pkg/cloud/cloud.go
Outdated
|
||
func getVolumeAttachmentsList(volume *ec2.Volume) []string { | ||
var volumeAttachmentList []string | ||
if len(volume.Attachments) > 0 { |
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 you need this check?
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.
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, ",")) |
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.
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.
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 { |
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.
Can we also check if we're returning the correct instance id in the error message? It's a requirement from the spec.
4805335
to
8f68b67
Compare
pkg/cloud/cloud.go
Outdated
func getVolumeAttachmentsList(volume *ec2.Volume) []string { | ||
var volumeAttachmentList []string | ||
for _, attachment := range volume.Attachments { | ||
if attachment.State != nil && aws.StringValue(attachment.State) == "attached" { |
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.
Can we lowercase aws.StringValue(attachment.State)
just to be safe?
8f68b67
to
22d1383
Compare
22d1383
to
81f4bb1
Compare
/approve |
[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 |
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