-
Notifications
You must be signed in to change notification settings - Fork 38.9k
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 api/errors instead of raw etcd errors #10246
Conversation
GCE e2e build/test failed for commit d3eca56f71dc15684bce5f3fab767dfd99b8d659. |
d3eca56
to
a43f8b3
Compare
GCE e2e build/test passed for commit a43f8b3c68b0bd45551fd40be5d658bcfc040894. |
a43f8b3
to
5a29a71
Compare
GCE e2e build/test failed for commit 5a29a715e117630079e90487f7ae5d5e1ded4dd9. |
5a29a71
to
fa1f8d7
Compare
GCE e2e build/test failed for commit fa1f8d7aba7777d5e456af6feed93b77a59b3ca7. |
fa1f8d7
to
f609e8f
Compare
GCE e2e build/test failed for commit f609e8f6762ca581b6478e6db4dcf5f25166775d. |
f609e8f
to
f9eaf95
Compare
Adding to v1 since the associated bug is marked v1. |
GCE e2e build/test failed for commit f9eaf959d03e1570ddcc6f95c749bff0bfd063ea. |
@@ -31,7 +30,7 @@ import ( | |||
) | |||
|
|||
var ( | |||
errorUnableToAllocate = errors.New("unable to allocate") | |||
errorUnableToAllocate = k8serr.NewInternalError(fmt.Errorf("unable to allocate")) |
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.
Prefer errors.New if you don't have parameters to pass.
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.
It will still be converted to an InternalError, even if we do not generate one here.
The advantage of generating an InternalError here is that we can then compare that the returned error == errorUnableToAllocate.
Otherwise, we will have to do
error.Error() == NewInternalError(errorUnableToAllocate).Error()
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.
Please add a comment that this error shouldn't ever be returned to the user.
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.
Done.
GCE e2e build/test failed for commit f9eaf959d03e1570ddcc6f95c749bff0bfd063ea. |
GCE e2e build/test failed for commit f9eaf959d03e1570ddcc6f95c749bff0bfd063ea. |
f9eaf95
to
6240623
Compare
Rebased and updated code as per comments. |
GCE e2e build/test failed for commit 26d87b37379626554171907c32d53f58ad6aaabc. |
GCE e2e build/test passed for commit 4b7f7ce. |
Good enough for now. LGTM. |
Re-assigned to @lavalamp for another LGTM |
lgtm |
Return api/errors instead of raw etcd errors
I missed the review of this but this is a pretty substantial change to the intent of the etcd methods - those were transform only. This change prevents other code from further refining those errors. I would have been a -1 on this - we should be handling non API errors higher in the stack, or via a different method. We use this method to filter out known errors, not wrap all errors. |
Sorry about that @smarterclayton I thought that I had cc'd you on this but looks like I didnt. Can you give an example where other code wants to refine the etcd error? Are you talking about refining an etcd error into another etcd error? Does that sound fine? |
Let's revert and figure out the right solution. |
I don't know that we need to revert right now. Basically, the original idea was that those methods would filter known At one point we called this method before a switch somewhere (switch On Jun 30, 2015, at 9:28 PM, Nikhil Jindal notifications@github.com wrote: Sorry about that @smarterclayton https://github.com/smarterclayton I Can you give an example where other code wants to refine the etcd error? Does that sound fine? — |
We should document that, and ideally test it. It was non-obvious. |
It's broken in BindingREST assignPod:
and in generic/etcd Create():
On Wed, Jul 1, 2015 at 1:04 AM, Brian Grant notifications@github.com
Clayton Coleman | Lead Engineer, OpenShift |
Also in generic/etcd Update():
On Wed, Jul 1, 2015 at 10:11 AM, Clayton Coleman ccoleman@redhat.com
Clayton Coleman | Lead Engineer, OpenShift |
I don't see any other obvious uses of it in Kube. On Wed, Jul 1, 2015 at 10:12 AM, Clayton Coleman ccoleman@redhat.com
Clayton Coleman | Lead Engineer, OpenShift |
I do think it's valuable for there to be a "turn etcd error into api error On Wed, Jul 1, 2015 at 10:12 AM, Clayton Coleman ccoleman@redhat.com
Clayton Coleman | Lead Engineer, OpenShift |
Thanks for those pointers @smarterclayton. |
Revert "Merge pull request #10246 from nikhiljindal"
For #10064
Wrapping etcd errors in errors.NewInternalError(err)