-
Notifications
You must be signed in to change notification settings - Fork 167
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
Introduce Kubeclient::ResourceNotFoundError #233
Conversation
@moolitayer @cben can you review? (It seems backward compatible to me but maybe you can spot something). |
Looks safe. The problem this partially solves (as did #221) is we eat up specific RestClient exception class, replacing them all with a single class. Are we gonna want to re-expose more RestClient exceptions this way? Is there a better way? Could we maybe inherit from RestClient's own exception classes? Can't inherit from 2 classes in ruby, so In any case, given that RestClient has close to 70 exception classes: https://gist.github.com/cben/892458b3ca8f8fa28d4962503fb446f0, I'd at least stick to its naming. |
@kirs BTW you can improve your code in the description by using the def self.delete_namespace(namespace)
kubeclient.delete_namespace(namespace)
rescue KubeException => e
raise unless e.error_code == 404
end Anyway it could be that |
Thought the same about testing the error_code vs. the message. I'm not sure how well this would scale in terms of different http error classes. I generally liked the approach @grosser suggested in #195 since
If we do decide to go this direction, I have a few nit pics:
@kirs thanks for including the example code, it's explains clearly what you are trying to achieve which is good 👍 [1] If i remember correctly #195 was supposed to do that, in a backward compatible manner? i.e add correct scoping but also still support the non scope param and deprecate it |
FYI would also be nice to use a http library that does not need native extensions (or depends on other gems) |
@grosser any suggestion? |
we use faraday a lot the middleware layering is a nice way of adding
reusable addons ... httpclient looks decent too and has no dependencies
…On Tue, Mar 14, 2017 at 8:29 AM, Federico Simoncelli < ***@***.***> wrote:
FYI would also be nice to use a http library that does not need native
extensions (or depends on other gems)
@grosser <https://github.com/grosser> any suggestion?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#233 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAsZz_HCygRKCjGnHfagy_b8YSFMgeXks5rlrJjgaJpZM4MZoZO>
.
|
@grosser can you please create an issue with this info? we can then get more feedback on it (and we would also want to switch clients in some other gems) |
rest-client issue moved to #237 |
Personally I don't think that there's any need for exception class per HTTP code.
There's a convention in Ruby to name exception classes as "errors". Good examples are Should I rebase my PR on top of #195? |
#195 has landed, please rebase (and inherit from the new |
@cben thanks, I rebased it. |
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.
Introduce Kubeclient::ResourceNotFoundError
Reverts parts of commit 263ff40 from ManageIQ#271 that restored KubeException - no longer needed after backporting ManageIQ#195 and ManageIQ#233, we now have Kubeclient::HttpError and Kubeclient::ResourceNotFoundError. In other words, v2.x branch is now closer to original ManageIQ#262.
Reverts parts of commit 263ff40 from ManageIQ#271 that restored KubeException - no longer needed after backporting ManageIQ#195 and ManageIQ#233, we now have Kubeclient::HttpError and Kubeclient::ResourceNotFoundError. In other words, v2.x branch is now closer to original ManageIQ#262.
This reverts commit 263ff40 from ManageIQ#271. Those backport changes are no longer needed: - after backporting ManageIQ#195 and ManageIQ#233, v2.x now has Kubeclient::HttpError and Kubeclient::ResourceNotFoundError. - after backporting ManageIQ#247, v2.x now tests with webmock 2.x, it takes `basic_auth` rather than user:pw in URL. - ns/namespace change was just cosmetic. In other words, v2.x branch is now closer to original ManageIQ#262.
Introduce Kubeclient::ResourceNotFoundError
This reverts commit 263ff40 from ManageIQ#271. Those backport changes are no longer needed: - after backporting ManageIQ#195 and ManageIQ#233, v2.x now has Kubeclient::HttpError and Kubeclient::ResourceNotFoundError. - after backporting ManageIQ#247, v2.x now tests with webmock 2.x, it takes `basic_auth` rather than user:pw in URL. - ns/namespace change was just cosmetic. In other words, v2.x branch is now closer to original ManageIQ#262.
First of all, thanks a lot for creating and maintaining the gem. It helps us a lot in building Kubernetes tools and scripts.
I'd like to to add a distinction between the generic error (
KubeException
) and the specific "not found" error. Right now in my code I have to do:This would be much easier if I could rescue only
ResourceNotFoundError
.cc @simon3z @KnVerey