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

Add MiqQueue#tracking_label #15224

Merged
merged 1 commit into from
Jun 23, 2017
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions app/models/miq_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def self.put(options)
options[:queue_name] ||= create_with_options[:queue_name] || "generic"
options[:msg_timeout] ||= create_with_options[:msg_timeout] || TIMEOUT
options[:task_id] = $_miq_worker_current_msg.try(:task_id) unless options.key?(:task_id)
options[:tracking_label] = Thread.current[:tracking_label] || options[:task_id] unless options.key?(:tracking_label)
options[:role] = options[:role].to_s unless options[:role].nil?

options[:args] = [options[:args]] if options[:args] && !options[:args].kind_of?(Array)
Expand Down
2 changes: 2 additions & 0 deletions app/models/miq_queue_worker_base/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def deliver_queue_message(msg)

begin
$_miq_worker_current_msg = msg
Thread.current[:tracking_label] = msg.tracking_label || msg.task_id
status, message, result = msg.deliver

if status == MiqQueue::STATUS_TIMEOUT
Expand All @@ -122,6 +123,7 @@ def deliver_queue_message(msg)
msg.unget
ensure
$_miq_worker_current_msg = nil # to avoid log messages inadvertantly prefixed by previous task_id
Thread.current[:tracking_label] = nil
#
# This tells the broker to release any memory being held on behalf of this process
# and reset the global broker handle ($vim_broker_client).
Expand Down