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

Return error when fetching the snapshot fails #233

Merged
merged 2 commits into from Dec 12, 2019

Conversation

timoreimann
Copy link
Collaborator

We previously continued processing when fetching the snapshot failed for errors other than 404.

@@ -169,6 +169,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
if resp != nil && resp.StatusCode == http.StatusNotFound {
return nil, status.Errorf(codes.NotFound, "snapshot %q not found", snapshotID)
}
return nil, err
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We do not seem to return a proper gRPC status code in similar code paths either, so I copied the pattern. Not sure if good or not, my expectation/hope would be that gRPC maps this to a generic "internal error" or similar.

@adamwg you may know this one better than me.

Copy link
Contributor

@adamwg adamwg Dec 10, 2019

Choose a reason for hiding this comment

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

I believe the go gRPC framework wraps non-gRPC errors from RPC handlers using the Unknown status code. I always prefer to return explicit gRPC errors with appropriate codes from handlers, but gRPC is OK with it either way.

Makes sense to follow the general pattern here, and if we want to return explicit Internals everywhere we can do that in a separate PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense to me -- will keep that in mind for a follow up PR.

Copy link
Contributor

@adamwg adamwg left a comment

Choose a reason for hiding this comment

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

LGTM.

Are there any unit tests that cover this code? If so, it would be nice to add a test case to catch this.

@timoreimann
Copy link
Collaborator Author

I added TestCreateVolume and covered two exemplary cases, one of them addressing the code modified. Let me know what you think.

@timoreimann timoreimann force-pushed the return-error-when-fetching-a-snapshot-fails branch 2 times, most recently from 7c2708e to ed1d4c3 Compare December 12, 2019 10:36
We previously continued processing when fetching the snapshot failed for
errors other than 404.
@timoreimann timoreimann force-pushed the return-error-when-fetching-a-snapshot-fails branch from ed1d4c3 to 8e89fc3 Compare December 12, 2019 10:36
@timoreimann timoreimann merged commit dbcb92c into master Dec 12, 2019
@timoreimann timoreimann deleted the return-error-when-fetching-a-snapshot-fails branch December 12, 2019 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants