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

Default to StandardError if a connection cannot be made #278

Merged
merged 1 commit into from
Jul 16, 2018
Merged

Default to StandardError if a connection cannot be made #278

merged 1 commit into from
Jul 16, 2018

Conversation

djberg96
Copy link
Collaborator

@djberg96 djberg96 commented Jul 16, 2018

Currently the connection_rescue_block is defaulting to a MiqCredentialsError as a last resort when an unexpected connection error occurs. As per @jrafanie's advice, this should be changed to re-raise StandardError so that more graceful handling will occur via the AuthenticationMixin module from the core repo, since it is now a "valid" error.

It's also just more sensical since by the time we fall into this bucket, since it's probably not an actual credentials error.

While we obviously cannot solve problems on Azure's end (which is typically when this error will be reached), we can handle it more gracefully with this change.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1600968

@djberg96
Copy link
Collaborator Author

@@ -50,7 +50,7 @@ def connection_rescue_block
raise # Raise before falling into catch-all block below
rescue StandardError => err
_log.error("Error Class=#{err.class.name}, Message=#{err.message}, Backtrace=#{err.backtrace}")
raise MiqException::MiqInvalidCredentialsError, _("Unexpected response returned from system: %{error_message}") % {:error_message => err.message}
raise MiqException::MiqUnreachableError, _("Unexpected response returned from system: %{error_message}") % {:error_message => err.message}
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps it makes sense to just re-raise err because we're not really sure it's unreachable at this point. We treat StandardError exceptions the same as MiqUnreachableError: we retry more frequently with an exponential backoff. The problem was that we were explicitly raising MiqInvalidCredentialsError, an exception we don't retry as frequently.

https://github.com/ManageIQ/manageiq/blob/d101c7997d556f08a7b0747703654ba74915b7da/app/models/mixins/authentication_mixin.rb#L401-L409

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jrafanie Fair enough, I'll change it.

Fall back to just using StandardError on connection failure.
@miq-bot
Copy link
Member

miq-bot commented Jul 16, 2018

Checked commit https://github.com/djberg96/manageiq-providers-azure/commit/79b6e737fb90140ab51ab4a77837ec29b195f9cf with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 👍

@djberg96 djberg96 changed the title Default to MiqUnreachableError if a connection cannot be made Default to StandardError if a connection cannot be made Jul 16, 2018
Copy link
Member

@jrafanie jrafanie left a comment

Choose a reason for hiding this comment

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

LGTM

@bronaghs bronaghs merged commit 745543c into ManageIQ:master Jul 16, 2018
@bronaghs bronaghs added the bug label Jul 16, 2018
@simaishi
Copy link
Contributor

@djberg96 Can this be gaprindashvili/yes?

@djberg96
Copy link
Collaborator Author

@simaishi Yes, tagged.

simaishi pushed a commit that referenced this pull request Jul 19, 2018
Default to StandardError if a connection cannot be made
(cherry picked from commit 745543c)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1601589
@simaishi
Copy link
Contributor

Gaprindashvili backport details:

$ git log -1
commit 78cb5e84e41f9969e37eca7283a7653b62636562
Author: Bronagh Sorota <[email protected]>
Date:   Mon Jul 16 14:33:34 2018 -0400

    Merge pull request #278 from djberg96/unreachable
    
    Default to StandardError if a connection cannot be made
    (cherry picked from commit 745543cdfd81c3883a93f2f1cc59caaa86e31ad6)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1601589

@bronaghs bronaghs added this to the Sprint 90 Ending Jul 16, 2018 milestone Jul 30, 2018
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.

5 participants