-
Notifications
You must be signed in to change notification settings - Fork 897
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
bdunne
merged 1 commit into
ManageIQ:master
from
agrare:fix_exception_missing_messaging_yml
Apr 8, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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? | ||
|
||
ManageIQ::Messaging::Client.open(options) | ||
rescue => err | ||
_log.warn("Failed to open messaging client: #{err}") | ||
nil | ||
|
@@ -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)) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 theSorry misread the diff.&.merge
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok