Skip to content

Commit

Permalink
Move the logging for sync_config out of the sync_config method
Browse files Browse the repository at this point in the history
This was a problem for the EventCatcher when sync_config was called
as a part of worker initialization. The EventCatcher uses its ems
hostname as a part of its log prefix, but the ems isn't set up until
after the first call to sync_config.

This was leading to errors when the worker was starting:
[----] I, [2019-12-19T17:51:48.407958 ManageIQ#11054:2ab1a6d9a5f8]  INFO -- : Starting ManageIQ::Providers::Vmware::InfraManager::EventCatcher with runner options {:ems_id=>"2", :guid=>"43a315ba-39ff-4326-99a6-89b3af48b1ee"}
[----] I, [2019-12-19T17:51:48.451836 ManageIQ#11054:2ab1a6d9a5f8]  INFO -- : Deleting worker record for ManageIQ::Providers::Vmware::InfraManager::EventCatcher, id 310
/home/ncarboni/Source/manageiq/app/models/manageiq/providers/base_manager/event_catcher/runner.rb:63:in `log_prefix': undefined method `hostname' for nil:NilClass (NoMethodError)
        from /home/ncarboni/Source/manageiq/app/models/miq_worker/runner.rb:242:in `sync_config'
        from /home/ncarboni/Source/manageiq/app/models/miq_worker/runner.rb:52:in `worker_initialization'
        from /home/ncarboni/Source/manageiq/app/models/miq_worker/runner.rb:42:in `initialize'
        from /home/ncarboni/Source/manageiq/lib/workers/bin/run_single_worker.rb:113:in `new'
        from /home/ncarboni/Source/manageiq/lib/workers/bin/run_single_worker.rb:113:in `<main>'
  • Loading branch information
carbonin authored and aufi committed Jan 29, 2020
1 parent e548cd2 commit a11075e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/models/miq_worker/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ def do_exit(message = nil, exit_code = 0)
end

def sync_config
_log.info("#{log_prefix} Synchronizing configuration...")
# Sync roles
@active_roles = MiqServer.my_active_roles(true)
after_sync_active_roles
Expand All @@ -258,7 +257,6 @@ def sync_config
$log.log_hashes(@cfg)

@worker.release_db_connection if @worker.respond_to?(:release_db_connection)
_log.info("#{log_prefix} Synchronizing configuration complete...")
end

def sync_log_level
Expand Down Expand Up @@ -324,7 +322,12 @@ def heartbeat

heartbeat_to_file

sync_config if config_out_of_date?
if config_out_of_date?
_log.info("#{log_prefix} Synchronizing configuration...")
sync_config
_log.info("#{log_prefix} Synchronizing configuration complete...")
end

process_messages_from_server unless MiqEnvironment::Command.is_podified?

@last_hb = now
Expand Down

0 comments on commit a11075e

Please sign in to comment.