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

Delegate queue_name for refresh to parent manager instead of queue_name arrays #20345

Merged
merged 1 commit into from
Oct 2, 2020
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
2 changes: 1 addition & 1 deletion app/models/ems_refresh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def self.get_target_objects(target, single_id = nil)

def self.queue_merge(targets, ems, create_task = false)
queue_options = {
:queue_name => ems.queue_name,
:queue_name => ems.queue_name_for_ems_refresh,
:class_name => name,
:method_name => 'refresh',
:role => "ems_inventory",
Expand Down
4 changes: 4 additions & 0 deletions app/models/ext_management_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,10 @@ def queue_name_for_ems_operations
'generic'
end

def queue_name_for_ems_refresh
queue_name
end

def enforce_policy(target, event)
inputs = {:ext_management_system => self}
inputs[:vm] = target if target.kind_of?(Vm)
Expand Down
11 changes: 0 additions & 11 deletions app/models/manageiq/providers/base_manager/refresh_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@ class ManageIQ::Providers::BaseManager::RefreshWorker < MiqQueueWorkerBase
self.include_stopping_workers_on_synchronize = true
self.required_roles = %w[ems_inventory]

def self.queue_name_for_ems(ems)
return ems unless ems.kind_of?(ExtManagementSystem)
return ems.queue_name unless ems.child_managers.any?
combined_managers(ems).map(&:queue_name).sort
end

def self.combined_managers(ems)
[ems].concat(ems.child_managers)
end
private_class_method :combined_managers

def friendly_name
@friendly_name ||= begin
ems = ext_management_system
Expand Down
2 changes: 2 additions & 0 deletions app/models/manageiq/providers/network_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class << model_name
:class_name => "ManageIQ::Providers::BaseManager",
:autosave => true

delegate :queue_name_for_ems_refresh, :to => :parent_manager

has_many :availability_zones, -> { where.not(:ems_id => nil) }, :primary_key => :parent_ems_id, :foreign_key => :ems_id
has_many :flavors, -> { where.not(:ems_id => nil) }, :primary_key => :parent_ems_id, :foreign_key => :ems_id
has_many :cloud_tenants, -> { where.not(:ems_id => nil) }, :primary_key => :parent_ems_id, :foreign_key => :ems_id
Expand Down
2 changes: 2 additions & 0 deletions app/models/manageiq/providers/storage_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class StorageManager < ManageIQ::Providers::BaseManager
:class_name => "ManageIQ::Providers::BaseManager",
:autosave => true

delegate :queue_name_for_ems_refresh, :to => :parent_manager

def self.display_name(number = 1)
n_('Storage Manager', 'Storage Managers', number)
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def self.submit_job(options)
# options[:queue_name] = "generic"
options[:role] = service
when "ems_inventory"
options[:queue_name] = MiqEmsRefreshWorker.queue_name_for_ems(resource)
options[:queue_name] = resource.queue_name_for_ems_refresh
options[:role] = service
options[:zone] = resource.my_zone
when "ems_operations"
Expand Down
12 changes: 0 additions & 12 deletions app/models/miq_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,18 +274,6 @@ def self.log_status_all(level = :info)
MiqWorker.log_status(level)
end

# Overriding queue_name as now some queue names can be
# arrays of names for some workers not just a singular name.
# We use JSON.parse as the array of names is stored as a string.
# This converts it back to a Ruby Array safely.
def queue_name
begin
JSON.parse(self[:queue_name]).sort
rescue JSON::ParserError, TypeError
self[:queue_name]
end
end

def self.containerized_worker?
MiqEnvironment::Command.is_podified?
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/mixins/per_ems_worker_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def parse_ems_id(queue_name)
end

def ems_id_from_queue_name(queue_name)
queue_name.kind_of?(Array) ? queue_name.collect { |q| parse_ems_id(q) }.flatten : parse_ems_id(queue_name)
parse_ems_id(queue_name)
end

def ems_from_queue_name(queue_name)
Expand Down