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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions app/models/miq_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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


ManageIQ::Messaging::Client.open(options)
rescue => err
_log.warn("Failed to open messaging client: #{err}")
nil
Expand Down Expand Up @@ -643,10 +646,10 @@ def self.optional_values(options, keys = [:zone])
private_class_method :optional_values

def self.messaging_client_options
(messaging_options_from_env || messaging_options_from_file).merge(
(messaging_options_from_env || messaging_options_from_file)&.merge(
: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?

end
private_class_method :messaging_client_options

Expand Down