-
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
SSLError not always translated to KubeException #240
Comments
|
Based on the link @cben posted I think we should catch OpenSSL::SSL::SSLError to keep the behavior we have (or thought we had). Introducing a new subclass sound good but I'd like to see this resolved first. @cben do you plan to send a PR for this? I have some time to do that, let me know |
Some test code and different exceptions I got test coderequire 'kubeclient'
cert_store = OpenSSL::X509::Store.new
cert_store.add_cert(OpenSSL::X509::Certificate.new(IO.read('ca_bad.crt')))
ssl_options = {
cert_store: cert_store,
verify_ssl: OpenSSL::SSL::VERIFY_PEER
}
client = Kubeclient::Client.new(
'https://vm-48-131.eng.lab.tlv.redhat.com:8443',
'v1',
:ssl_options => ssl_options,
:auth_options => {:bearer_token => token}
)
puts client.get_nodes
I'm not sure we should catch & wrap, what rest client is doing is silly. It should be fix in rest client. Also It would break backward compatibility as @cben mentioned. So I'm favor of not changing anything in kubeclient |
Is there an issue reported on this to rest client repo? |
rest-client/rest-client#168 (from 2013) |
Expands ManageIQ#314. KubeException already covers the common "certificate verify failed" SSL errors but not rarer ones like "does not match the server certificate". This might be resolved in Kubeclient or RestClient one day (ManageIQ/kubeclient#240) but it's blocked on backward compatibility concerns so let's catch it here for now. get_hostname_from_routes is best-effort, should never crash UI. Any SSL error will probably fail both get_hostname_from_routes and the main validation code; the error from validation will then be displayed in a red flash. https://bugzilla.redhat.com/show_bug.cgi?id=1436221
ssl errors and a few others are not retried atm leading to failing deploys ManageIQ/kubeclient#240
ssl errors and a few others are not retried atm leading to failing deploys ManageIQ/kubeclient#240
ssl errors and a few others are not retried atm leading to failing deploys ManageIQ/kubeclient#240
ssl errors and a few others are not retried atm leading to failing deploys ManageIQ/kubeclient#240
ssl errors and a few others are not retried atm leading to failing deploys ManageIQ/kubeclient#240
ssl errors and a few others are not retried atm leading to failing deploys ManageIQ/kubeclient#240
ssl errors and a few others are not retried atm leading to failing deploys ManageIQ/kubeclient#240
ssl errors and a few others are not retried atm leading to failing deploys ManageIQ/kubeclient#240
I propose for kubeclient 3, we solve this by adding Kubeclient::SSLError which will wrap both OpenSSL::SSL::SSLError and RestClient::SSLCertificateNotVerified.
|
@grosser any opinion/advice? I see we can learn from your workarounds...
|
rescuing all and having error_code nil for ssl/ECONNREFUSED could be good
... the error.cause will always point to the original
…On Tue, Jan 23, 2018 at 2:27 AM, Beni Cherniavsky-Paskin < ***@***.***> wrote:
@grosser <https://github.com/grosser> any opinion/advice? I see we can
learn from your workarounds...
- https://github.com/zendesk/samson/pull/2388/files#diff-
cd8b4517098ba133e33da78bca46c6bdR14
<https://github.com/zendesk/samson/pull/2388/files#diff-cd8b4517098ba133e33da78bca46c6bdR14>
— users also have to deal with os-level network errors. You also catch
ECONNREFUSED there. And we saw EBADF in #280
<#280> (though that was
internally caused, now we catch it).
I don't think we want to wrap OS errors. I wouldn't suggest wrapping
SSL if RestClient didn't make a mess of it :-)
- zendesk/samson#2391 <zendesk/samson#2391> —
it's annoying that HttpError doesn't always have error_code. It's not
only SSL that doesn't, but if we subclass HttpError it'll contribute to the
problem.
RestClient has a separate ExceptionWithResponse class
<http://www.rubydoc.info/github/rest-client/rest-client/RestClient/ExceptionWithResponse>.
So one way is to split something like Kubeclient::HttpErrorWithResponse
< Kubeclient::HttpError. meh.
Perhaps just ensure HttpError always responds to .error_code but
sometimes returns nil?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#240 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAsZxv5wxZhDHwwstRMVGYmz1o-CP5cks5tNbQOgaJpZM4Mq2kK>
.
|
There is a specific test that it should be (and #195 will add a second test):
https://github.com/abonas/kubeclient/blob/f489a35027a7/test/test_kubeclient.rb#L95-L105
but in reality I'm seeing an SSLError escaping:
https://gist.github.com/cben/faf8a9f7f104561c0b36c88ae02f2509
That makes sense,
handle_exception
only rescuesRestClient::Exception
.Why does the test pass?
Aha. RestClient has its own http://www.rubydoc.info/github/rest-client/rest-client/RestClient/SSLCertificateNotVerified, wraps some
SSLError
s:https://github.com/rest-client/rest-client/blob/8874463a4/lib/restclient/request.rb#L742-L761
In above gist the message was "hostname ... does not match the server certificate", not "certificate verify failed", so it isn't wrapped.
I think either change would be slightly backward-incompatible.
The text was updated successfully, but these errors were encountered: