From 9e99ba02ebdda05cb072ee36a54622227bb1ac52 Mon Sep 17 00:00:00 2001 From: Jason Frey Date: Tue, 25 Jul 2017 14:52:35 -0400 Subject: [PATCH] Reverse the default of wait_for_worker_monitor A majority of workers do not need to wait for the server to start, so changing the default simplifies the code and also identifies which workers actually need to wait. In researching this, we found that the only reason that workers are waiting is to actually wait for the vmware broker to start and provide its connection pool. Follow up PRs will change this from wait_for_worker_monitor to "wait for broker", and we can further make this more specific to vmware only classes. See also https://github.com/ManageIQ/manageiq/pull/14257#issuecomment-317818016 for a description of how the wait_for_worker_monitor manifests as a "wait for broker" scenario. --- app/models/embedded_ansible_worker/runner.rb | 2 -- .../manageiq/providers/base_manager/event_catcher/runner.rb | 2 -- .../providers/base_manager/metrics_collector_worker/runner.rb | 1 + .../manageiq/providers/base_manager/refresh_worker/runner.rb | 2 ++ app/models/miq_ems_refresh_core_worker/runner.rb | 2 -- app/models/miq_generic_worker/runner.rb | 1 + app/models/miq_priority_worker/runner.rb | 1 - app/models/miq_smart_proxy_worker/runner.rb | 1 + app/models/miq_vim_broker_worker/runner.rb | 2 -- app/models/miq_worker/runner.rb | 3 +-- app/models/mixins/miq_web_server_runner_mixin.rb | 4 ---- 11 files changed, 6 insertions(+), 15 deletions(-) diff --git a/app/models/embedded_ansible_worker/runner.rb b/app/models/embedded_ansible_worker/runner.rb index d596c86bb60..af355073d32 100644 --- a/app/models/embedded_ansible_worker/runner.rb +++ b/app/models/embedded_ansible_worker/runner.rb @@ -1,6 +1,4 @@ class EmbeddedAnsibleWorker::Runner < MiqWorker::Runner - self.wait_for_worker_monitor = false - def prepare ObjectSpace.garbage_collect # Overriding prepare so we can set started when we're ready diff --git a/app/models/manageiq/providers/base_manager/event_catcher/runner.rb b/app/models/manageiq/providers/base_manager/event_catcher/runner.rb index 9d619414150..9c6ebeeaa4b 100644 --- a/app/models/manageiq/providers/base_manager/event_catcher/runner.rb +++ b/app/models/manageiq/providers/base_manager/event_catcher/runner.rb @@ -8,8 +8,6 @@ class EventCatcherHandledException < StandardError include DuplicateBlocker - self.wait_for_worker_monitor = false - OPTIONS_PARSER_SETTINGS = ::MiqWorker::Runner::OPTIONS_PARSER_SETTINGS + [ [:ems_id, 'EMS Instance ID', String], ] 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 bc5d0b80ac4..58d4a642666 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,2 +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 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 45d977026eb..f204fe39712 100644 --- a/app/models/manageiq/providers/base_manager/refresh_worker/runner.rb +++ b/app/models/manageiq/providers/base_manager/refresh_worker/runner.rb @@ -3,6 +3,8 @@ 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 + def log_prefix @log_prefix ||= "EMS [#{@ems.hostname}] as [#{@ems.authentication_userid}]" end diff --git a/app/models/miq_ems_refresh_core_worker/runner.rb b/app/models/miq_ems_refresh_core_worker/runner.rb index 672cc30ffb3..d09858930b4 100644 --- a/app/models/miq_ems_refresh_core_worker/runner.rb +++ b/app/models/miq_ems_refresh_core_worker/runner.rb @@ -1,8 +1,6 @@ require 'thread' class MiqEmsRefreshCoreWorker::Runner < MiqWorker::Runner - self.wait_for_worker_monitor = false - OPTIONS_PARSER_SETTINGS = MiqWorker::Runner::OPTIONS_PARSER_SETTINGS + [ [:ems_id, 'EMS Instance ID', String], ] diff --git a/app/models/miq_generic_worker/runner.rb b/app/models/miq_generic_worker/runner.rb index e05822e629e..f6c9a72b724 100644 --- a/app/models/miq_generic_worker/runner.rb +++ b/app/models/miq_generic_worker/runner.rb @@ -1,2 +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 end diff --git a/app/models/miq_priority_worker/runner.rb b/app/models/miq_priority_worker/runner.rb index 40e76f39832..0a64216874c 100644 --- a/app/models/miq_priority_worker/runner.rb +++ b/app/models/miq_priority_worker/runner.rb @@ -1,3 +1,2 @@ class MiqPriorityWorker::Runner < MiqQueueWorkerBase::Runner - self.wait_for_worker_monitor = false end diff --git a/app/models/miq_smart_proxy_worker/runner.rb b/app/models/miq_smart_proxy_worker/runner.rb index 0ff09088aec..3570412b3eb 100644 --- a/app/models/miq_smart_proxy_worker/runner.rb +++ b/app/models/miq_smart_proxy_worker/runner.rb @@ -1,2 +1,3 @@ class MiqSmartProxyWorker::Runner < MiqQueueWorkerBase::Runner + self.wait_for_worker_monitor = true # NOTE: Really means wait for broker to start for smartproxy role end diff --git a/app/models/miq_vim_broker_worker/runner.rb b/app/models/miq_vim_broker_worker/runner.rb index b6c0fc2656c..7e79d1d66e9 100644 --- a/app/models/miq_vim_broker_worker/runner.rb +++ b/app/models/miq_vim_broker_worker/runner.rb @@ -1,6 +1,4 @@ class MiqVimBrokerWorker::Runner < MiqWorker::Runner - self.wait_for_worker_monitor = false - def after_initialize require 'thread' diff --git a/app/models/miq_worker/runner.rb b/app/models/miq_worker/runner.rb index a90cdd7f1a4..a893065c7c1 100644 --- a/app/models/miq_worker/runner.rb +++ b/app/models/miq_worker/runner.rb @@ -84,8 +84,7 @@ def set_connection_pool_size ############################### def self.wait_for_worker_monitor? - @wait_for_worker_monitor = true if @wait_for_worker_monitor.nil? - @wait_for_worker_monitor + !!@wait_for_worker_monitor end class << self diff --git a/app/models/mixins/miq_web_server_runner_mixin.rb b/app/models/mixins/miq_web_server_runner_mixin.rb index d7a3c4c7fde..47eb00a1905 100644 --- a/app/models/mixins/miq_web_server_runner_mixin.rb +++ b/app/models/mixins/miq_web_server_runner_mixin.rb @@ -1,10 +1,6 @@ module MiqWebServerRunnerMixin extend ActiveSupport::Concern - included do - self.wait_for_worker_monitor = false - end - def do_work end