diff --git a/app/models/miq_server/worker_management/heartbeat.rb b/app/models/miq_server/worker_management/heartbeat.rb index 58f9bf547af..235a9f090ac 100644 --- a/app/models/miq_server/worker_management/heartbeat.rb +++ b/app/models/miq_server/worker_management/heartbeat.rb @@ -31,25 +31,10 @@ def worker_heartbeat(worker_pid, worker_class = nil, queue_name = nil) h[:queue_name] ||= queue_name end unless @workers_lock.nil? - # Special process the sync_ messages to send the current values of what to synchronize - messages.collect do |message, *args| - case message - when "sync_active_roles" - [message, {:roles => @active_role_names}] - else - [message, *args] - end - end + messages end def worker_set_message(w, message, *args) - # Special process for this compound message, by breaking it up into 2 simpler messages - if message == 'sync_active_roles_and_config' - worker_set_message(w, 'sync_active_roles') - worker_set_message(w, 'sync_config') - return - end - _log.info("#{w.format_full_log_msg} is being requested to #{message}") @workers_lock.synchronize(:EX) do worker_add_message(w.pid, [message, *args]) if @workers.key?(w.pid) diff --git a/app/models/miq_server/worker_management/monitor.rb b/app/models/miq_server/worker_management/monitor.rb index 2d5c1ba53f0..2b3a9286e61 100644 --- a/app/models/miq_server/worker_management/monitor.rb +++ b/app/models/miq_server/worker_management/monitor.rb @@ -135,13 +135,7 @@ def sync_needed? if resync_needed @last_sync = Time.now.utc - if (config_changed && roles_changed) || sync_interval_reached - sync_message = "sync_active_roles_and_config" - elsif config_changed - sync_message = "sync_config" - else - sync_message = "sync_active_roles" - end + sync_message = "sync_config" sync_config if config_changed sync_assigned_roles if config_changed diff --git a/app/models/miq_worker/runner.rb b/app/models/miq_worker/runner.rb index 015bc707b9c..d70bfe6747b 100644 --- a/app/models/miq_worker/runner.rb +++ b/app/models/miq_worker/runner.rb @@ -59,7 +59,6 @@ def worker_initialization starting_worker_record set_process_title # Sync the config and roles early since heartbeats and logging require the configuration - sync_active_roles sync_config set_connection_pool_size @@ -267,13 +266,6 @@ def message_restarted(*_args) # just consume the restarted message end - def message_sync_active_roles(*args) - _log.info("#{log_prefix} Synchronizing active roles...") - opts = args.extract_options! - sync_active_roles(opts[:roles]) - _log.info("#{log_prefix} Synchronizing active roles complete...") - end - def message_sync_config(*_args) _log.info("#{log_prefix} Synchronizing configuration...") sync_config @@ -281,16 +273,23 @@ def message_sync_config(*_args) end def sync_config + # Sync roles + @active_roles = MiqServer.my_active_roles(true) + after_sync_active_roles + + # Sync settings Vmdb::Settings.reload! @my_zone ||= MiqServer.my_zone sync_log_level sync_worker_settings sync_blacklisted_events - _log.info("ID [#{@worker.id}], PID [#{@worker.pid}], GUID [#{@worker.guid}], Zone [#{@my_zone}], Active Roles [#{@active_roles.join(',')}], Assigned Roles [#{MiqServer.my_role}], Configuration:") + after_sync_config + + _log.info("ID [#{@worker.id}], PID [#{Process.pid}], GUID [#{@worker.guid}], Zone [#{@my_zone}], Active Roles [#{@active_roles.join(',')}], Assigned Roles [#{MiqServer.my_role}], Configuration:") $log.log_hashes(@worker_settings) $log.info("---") $log.log_hashes(@cfg) - after_sync_config + @worker.release_db_connection if @worker.respond_to?(:release_db_connection) end @@ -305,11 +304,6 @@ def sync_worker_settings poll_method end - def sync_active_roles(role_names = nil) - @active_roles = role_names || MiqServer.my_active_roles(true) - after_sync_active_roles - end - # # Work methods # diff --git a/spec/models/miq_ems_refresh_core_worker/runner_spec.rb b/spec/models/miq_ems_refresh_core_worker/runner_spec.rb index 3ed3e6617aa..ea8be467b86 100644 --- a/spec/models/miq_ems_refresh_core_worker/runner_spec.rb +++ b/spec/models/miq_ems_refresh_core_worker/runner_spec.rb @@ -5,7 +5,6 @@ # General stubbing for testing any worker (methods called during initialize) @worker_record = FactoryGirl.create(:miq_ems_refresh_core_worker, :queue_name => "ems_#{@ems.id}", :miq_server => server) - allow_any_instance_of(described_class).to receive(:sync_active_roles) allow_any_instance_of(described_class).to receive(:sync_config) allow_any_instance_of(described_class).to receive(:set_connection_pool_size) allow_any_instance_of(described_class).to receive(:heartbeat_using_drb?).and_return(false) diff --git a/spec/models/miq_queue_worker_base/runner_spec.rb b/spec/models/miq_queue_worker_base/runner_spec.rb index 63193f6a3ab..b2270402e65 100644 --- a/spec/models/miq_queue_worker_base/runner_spec.rb +++ b/spec/models/miq_queue_worker_base/runner_spec.rb @@ -3,7 +3,6 @@ let(:server) { EvmSpecHelper.local_miq_server } let(:worker) { FactoryGirl.create(:miq_generic_worker, :miq_server => server, :pid => 123) } let(:runner) do - allow_any_instance_of(MiqQueueWorkerBase::Runner).to receive(:sync_active_roles) allow_any_instance_of(MiqQueueWorkerBase::Runner).to receive(:sync_config) allow_any_instance_of(MiqQueueWorkerBase::Runner).to receive(:set_connection_pool_size) described_class.new(:guid => worker.guid) diff --git a/spec/models/miq_schedule_worker/runner_spec.rb b/spec/models/miq_schedule_worker/runner_spec.rb index c3103ee357c..4a04f7536b3 100644 --- a/spec/models/miq_schedule_worker/runner_spec.rb +++ b/spec/models/miq_schedule_worker/runner_spec.rb @@ -8,7 +8,6 @@ @worker = FactoryGirl.create(:miq_schedule_worker, :guid => worker_guid, :miq_server_id => @miq_server.id) allow_any_instance_of(MiqScheduleWorker::Runner).to receive(:initialize_rufus) - allow_any_instance_of(MiqScheduleWorker::Runner).to receive(:sync_active_roles) allow_any_instance_of(MiqScheduleWorker::Runner).to receive(:sync_config) allow_any_instance_of(MiqScheduleWorker::Runner).to receive(:set_connection_pool_size) diff --git a/spec/models/miq_server/worker_monitor_spec.rb b/spec/models/miq_server/worker_monitor_spec.rb index 698ed31bcce..f479ee2f5aa 100644 --- a/spec/models/miq_server/worker_monitor_spec.rb +++ b/spec/models/miq_server/worker_monitor_spec.rb @@ -288,37 +288,6 @@ end end - context "when server has a single sync_active_roles message" do - before(:each) do - @miq_server.message_for_worker(@worker1.id, "sync_active_roles") - end - - it "should return proper message on heartbeat via drb" do - expect(@miq_server.worker_heartbeat(@worker1.pid)).to eq([['sync_active_roles', {:roles => nil}]]) - end - end - - context "#stop_worker followed by a single sync_active_roles_and_config message" do - before(:each) do - @miq_server.stop_worker(@worker1) - @miq_server.message_for_worker(@worker1.id, "sync_active_roles_and_config") - end - - it "exit message followed by active_roles and config" do - expect(@miq_server.worker_heartbeat(@worker1.pid)).to eq([['exit'], ['sync_active_roles', {:roles => nil}], ['sync_config']]) - end - end - - context "when server has a single sync_active_roles_and_config message" do - before(:each) do - @miq_server.message_for_worker(@worker1.id, "sync_active_roles_and_config") - end - - it "should return proper message on heartbeat via drb" do - expect(@miq_server.worker_heartbeat(@worker1.pid)).to eq([['sync_active_roles', {:roles => nil}], ['sync_config']]) - end - end - context "when server has a single reconnect_ems message with a parameter" do before(:each) do @ems_id = 7 diff --git a/spec/models/miq_vim_broker_worker/runner_spec.rb b/spec/models/miq_vim_broker_worker/runner_spec.rb index c4598608b56..de0bd9665a1 100644 --- a/spec/models/miq_vim_broker_worker/runner_spec.rb +++ b/spec/models/miq_vim_broker_worker/runner_spec.rb @@ -13,7 +13,6 @@ @worker_record = FactoryGirl.create(:miq_vim_broker_worker, :guid => @worker_guid, :miq_server_id => server.id) @drb_uri = "drb://127.0.0.1:12345" allow(DRb).to receive(:uri).and_return(@drb_uri) - allow_any_instance_of(described_class).to receive(:sync_active_roles) allow_any_instance_of(described_class).to receive(:sync_config) allow_any_instance_of(described_class).to receive(:set_connection_pool_size) allow_any_instance_of(ManageIQ::Providers::Vmware::InfraManager).to receive(:authentication_check).and_return([true, ""])