diff --git a/app/models/manageiq/providers/base_manager/metrics_collector_worker/runner.rb b/app/models/manageiq/providers/base_manager/metrics_collector_worker/runner.rb index 58d4a642666..e9137b4a0b2 100644 --- a/app/models/manageiq/providers/base_manager/metrics_collector_worker/runner.rb +++ b/app/models/manageiq/providers/base_manager/metrics_collector_worker/runner.rb @@ -1,3 +1,3 @@ class ManageIQ::Providers::BaseManager::MetricsCollectorWorker::Runner < ::MiqQueueWorkerBase::Runner - self.wait_for_worker_monitor = true # NOTE: Really means wait for broker to start for ems_metrics_collector role, TODO: only for VMware + self.delay_startup_for_vim_broker = true # NOTE: For ems_metrics_collector role, TODO: only for VMware end diff --git a/app/models/manageiq/providers/base_manager/refresh_worker/runner.rb b/app/models/manageiq/providers/base_manager/refresh_worker/runner.rb index f204fe39712..1f0cf7a488f 100644 --- a/app/models/manageiq/providers/base_manager/refresh_worker/runner.rb +++ b/app/models/manageiq/providers/base_manager/refresh_worker/runner.rb @@ -3,7 +3,7 @@ class ManageIQ::Providers::BaseManager::RefreshWorker::Runner < ::MiqQueueWorker [:ems_id, 'EMS Instance ID', String], ] - self.wait_for_worker_monitor = true # NOTE: Really means wait for broker for ems_inventory role, TODO: only for VMware + self.delay_startup_for_vim_broker = true # NOTE: For ems_inventory role, TODO: only for VMware def log_prefix @log_prefix ||= "EMS [#{@ems.hostname}] as [#{@ems.authentication_userid}]" diff --git a/app/models/miq_generic_worker/runner.rb b/app/models/miq_generic_worker/runner.rb index f6c9a72b724..022db94e872 100644 --- a/app/models/miq_generic_worker/runner.rb +++ b/app/models/miq_generic_worker/runner.rb @@ -1,3 +1,3 @@ class MiqGenericWorker::Runner < MiqQueueWorkerBase::Runner - self.wait_for_worker_monitor = true # NOTE: Really means wait for broker to start because of ems_operations and smartstate roles + self.delay_startup_for_vim_broker = true # NOTE: For ems_operations and smartstate roles end diff --git a/app/models/miq_queue_worker_base/runner.rb b/app/models/miq_queue_worker_base/runner.rb index 5a0f45d8a20..206066bd7ae 100644 --- a/app/models/miq_queue_worker_base/runner.rb +++ b/app/models/miq_queue_worker_base/runner.rb @@ -92,11 +92,7 @@ def get_message end def message_delivery_suspended? - if self.class.require_vim_broker? - return true unless MiqVimBrokerWorker.available? - end - - false + self.class.delay_queue_delivery_for_vim_broker? && !MiqVimBrokerWorker.available? end def deliver_queue_message(msg) diff --git a/app/models/miq_smart_proxy_worker/runner.rb b/app/models/miq_smart_proxy_worker/runner.rb index 3570412b3eb..893dd38ea25 100644 --- a/app/models/miq_smart_proxy_worker/runner.rb +++ b/app/models/miq_smart_proxy_worker/runner.rb @@ -1,3 +1,3 @@ class MiqSmartProxyWorker::Runner < MiqQueueWorkerBase::Runner - self.wait_for_worker_monitor = true # NOTE: Really means wait for broker to start for smartproxy role + self.delay_startup_for_vim_broker = true # NOTE: For smartproxy role end diff --git a/app/models/miq_worker/runner.rb b/app/models/miq_worker/runner.rb index a893065c7c1..015bc707b9c 100644 --- a/app/models/miq_worker/runner.rb +++ b/app/models/miq_worker/runner.rb @@ -83,21 +83,6 @@ def set_connection_pool_size # Worker Monitor Methods ############################### - def self.wait_for_worker_monitor? - !!@wait_for_worker_monitor - end - - class << self - attr_writer :wait_for_worker_monitor - end - - def my_monitor_started? - return @monitor_started unless @monitor_started.nil? - return false if server.nil? - return false unless server.reload.started? - @monitor_started = true - end - def worker_monitor_drb @worker_monitor_drb ||= begin raise _("%{log} No MiqServer found to establishing DRb Connection to") % {:log => log_prefix} if server.nil? @@ -120,13 +105,23 @@ def worker_monitor_drb # VimBrokerWorker Methods ############################### - def self.require_vim_broker? - @require_vim_broker = false if @require_vim_broker.nil? - @require_vim_broker + def self.delay_startup_for_vim_broker? + !!@delay_startup_for_vim_broker end class << self - attr_writer :require_vim_broker + attr_writer :delay_startup_for_vim_broker + end + + def self.delay_queue_delivery_for_vim_broker? + !!@delay_queue_delivery_for_vim_broker + end + + class << self + attr_writer :delay_queue_delivery_for_vim_broker + + alias require_vim_broker? delay_queue_delivery_for_vim_broker? + alias require_vim_broker= delay_queue_delivery_for_vim_broker= end def start @@ -151,7 +146,7 @@ def prepare set_database_application_name ObjectSpace.garbage_collect started_worker_record - do_wait_for_worker_monitor if self.class.wait_for_worker_monitor? + do_delay_startup_for_vim_broker if self.class.delay_startup_for_vim_broker? && MiqVimBrokerWorker.workers > 0 do_before_work_loop self end @@ -323,14 +318,14 @@ def do_work raise NotImplementedError, _("must be implemented in a subclass") end - def do_wait_for_worker_monitor - _log.info("#{log_prefix} Checking that worker monitor has started before doing work") + def do_delay_startup_for_vim_broker + _log.info("#{log_prefix} Checking that VIM Broker has started before doing work") loop do - break if self.my_monitor_started? + break if MiqVimBrokerWorker.available? heartbeat sleep 3 end - _log.info("#{log_prefix} Starting work since worker monitor has started") + _log.info("#{log_prefix} Starting work since VIM Broker has started") end def do_work_loop diff --git a/spec/models/miq_ui_worker/runner_spec.rb b/spec/models/miq_ui_worker/runner_spec.rb deleted file mode 100644 index 60e96f31181..00000000000 --- a/spec/models/miq_ui_worker/runner_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -describe MiqUiWorker::Runner do - it ".wait_for_worker_monitor?" do - expect(described_class.wait_for_worker_monitor?).to be_falsey - end -end