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

Fix messaging_client exception if no ENV and no yaml are present #20062

Merged
merged 1 commit into from
Apr 8, 2020

Conversation

agrare
Copy link
Member

@agrare agrare commented Apr 8, 2020

If the messaging_type is set to artemis or kafka but no ENV vars for messaging are set and no config/messaging.yml file is created the messaging_client_options method throws a NilClass exception.

WARN -- : MIQ(MiqQueue.messaging_client) Failed to open messaging client: undefined method 'merge' for nil:NilClass

If the messaging_type is set to artemis or kafka but no ENV vars for
messaging are set and no config/messaging.yml file is created the
messaging_client_options method throws a NilClass exception.
@miq-bot
Copy link
Member

miq-bot commented Apr 8, 2020

Checked commit agrare@8aa71e1 with ruby 2.5.7, rubocop 0.69.0, haml-lint 0.28.0, and yamllint
1 file checked, 0 offenses detected
Everything looks fine. ⭐

@@ -47,7 +47,10 @@ def self.messaging_client(client_ref)
# caching the client works, even if the connection becomes unavailable
# internally the client will track the state of the connection and re-open it,
# once it's available again - at least thats true for a stomp connection
ManageIQ::Messaging::Client.open(messaging_client_options.merge(:client_ref => client_ref))
options = messaging_client_options&.merge(:client_ref => client_ref)
return if options.nil?
Copy link
Member

@Fryguy Fryguy Apr 8, 2020

Choose a reason for hiding this comment

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

If you move this line up, then you don't need the &.merge Sorry misread the diff.

Copy link
Member

Choose a reason for hiding this comment

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

Should we also log an error message? Something along the lines of "Messaging type set to #{messaging_type}, but no configuration provided, falling back to miq_queue"

Copy link
Member Author

@agrare agrare Apr 8, 2020

Choose a reason for hiding this comment

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

Without some rate limiting that would be a log message for every event and metric that gets raised

Copy link
Member Author

Choose a reason for hiding this comment

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

I think when we are depending on the Messaging::Client connection we should raise an exception if the config is missing, right now it is just "in addition to" so wanted to keep the noise to a minimum

Copy link
Member

Choose a reason for hiding this comment

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

ok

:encoding => "json",
:protocol => messaging_protocol,
).tap { |h| h[:password] = MiqPassword.try_decrypt(h.delete(:password)) }
)&.tap { |h| h[:password] = MiqPassword.try_decrypt(h.delete(:password)) }
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense for this method to return an empty hash instead of nil?

@Fryguy
Copy link
Member

Fryguy commented Apr 8, 2020

Minor side comments, but otherwise LGTM

@bdunne bdunne merged commit d16c6e7 into ManageIQ:master Apr 8, 2020
@bdunne bdunne self-assigned this Apr 8, 2020
@agrare agrare deleted the fix_exception_missing_messaging_yml branch April 8, 2020 15:23
simaishi pushed a commit that referenced this pull request Apr 16, 2020
…_yml

Fix messaging_client exception if no ENV and no yaml are present

(cherry picked from commit d16c6e7)
@simaishi
Copy link
Contributor

Jansa backport details:

$ git log -1
commit 1e4d4d7a93fb00d5056b0a3d0de28ad02742bac9
Author: Brandon Dunne <[email protected]>
Date:   Wed Apr 8 11:22:59 2020 -0400

    Merge pull request #20062 from agrare/fix_exception_missing_messaging_yml

    Fix messaging_client exception if no ENV and no yaml are present

    (cherry picked from commit d16c6e728dd2a12d85fde8bde95d1c28a85e4f5a)

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.

6 participants