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

Rescue all errors in get_hostname_from_routes #1120

Closed

Conversation

cben
Copy link
Contributor

@cben cben commented Apr 23, 2017

#972 was not enough, e.g. OpenSSL::X509::CertificateError parsing errors still spill through.
Turns out OpenSSL::SSL::SSLError is not the parent of all openssl errors, that would be OpenSSL::OpenSSLError :-(

But I won't repeating the mistake a third time, let's catch everything. This function is a best-effort guess anyway.

https://bugzilla.redhat.com/show_bug.cgi?id=1436221 (master)
https://bugzilla.redhat.com/show_bug.cgi?id=1441670 (fine)
This is an improvement, but not a sufficient fixes.
I'll follow up with at least one PR to make the backend return exceptions as JSON. Should have done that long ago, would have saved a lot of effort testing & triaging.

Before, with a malformed custom CA:
trusted-ca-garbage-not-displayed

After:
trusted-ca-garbage-err

The "header is too long" message is too unclear :-( It's not even clear what field the error refers to.
This is a case where the model doesn't even pass rails validations, I'm looking at reporting this better...

@miq-bot add-label compute/containers, bug, fine/yes, blocker

@yaacov @moolitayer @AparnaKarve Please review.

ManageIQ#972 was not enough, e.g. OpenSSL::X509::CertificateError parsing
errors still spill through.  turns out OpenSSL::SSL::SSLError is not
the parent of all openssl errors, that would be OpenSSL::OpenSSLError.

But I won't repeating the mistake a third time, let's catch everything.
This function is a best-effort guess anyway.

https://bugzilla.redhat.com/show_bug.cgi?id=1436221
@miq-bot
Copy link
Member

miq-bot commented Apr 23, 2017

Checked commit cben@d647cd6 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
1 file checked, 0 offenses detected
Everything looks good. 🍪

@@ -475,7 +475,7 @@ def get_hostname_from_routes(ems, endpoint_hash, token)
client = ems.class.raw_connect(endpoint.hostname, endpoint.port,
:service => :openshift, :bearer => token, :ssl_options => ssl_options)
client.get_route('hawkular-metrics', 'openshift-infra').try(:spec).try(:host)
rescue KubeException, OpenSSL::SSL::SSLError => e
rescue StandardError => e
Copy link

@moolitayer moolitayer Apr 23, 2017

Choose a reason for hiding this comment

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

I think that is the same as rescue => bang
any way I think rescue KubeException, OpenSSL::SSL::OpenSSLError => e is better for us.
We would not like this to catch an undefined method for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm. Problem is unexpected exceptions crash UI in a way that doesn't reach user.
Let me make the other PR that reports them better to user, then I'll re-think this rescue...

@moolitayer
Copy link

moolitayer commented Apr 23, 2017

The "header is too long" message is too unclear :-( It's not even clear what field the error refers to.

you could go for a generic ssl validation error. that way you can easily satisfy internationalization and not worry about cutting long strings

@cben
Copy link
Contributor Author

cben commented Apr 24, 2017

Closing in favor of @yaacov's essentially same #1126.
He's seeing yet another exception Errno::ECONNREFUSED so catch-all seems to be correct solution.

@cben cben closed this Apr 24, 2017
@cben cben mentioned this pull request Apr 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants