Skip to content

Commit

Permalink
Rename #get_messages to #config_out_of_date? and call sync_config dir…
Browse files Browse the repository at this point in the history
…ectly

The indirection here was put in place to match the existing drb message
processing as closely as possible, now that that has been removed
this can be simplified.
  • Loading branch information
carbonin committed Jan 6, 2020
1 parent c9c3440 commit efb4593
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions app/models/miq_worker/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,8 @@ def do_exit(message = nil, exit_code = 0)
exit exit_code
end

def message_sync_config(*_args)
_log.info("#{log_prefix} Synchronizing configuration...")
sync_config
_log.info("#{log_prefix} Synchronizing configuration complete...")
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 @@ -263,6 +258,7 @@ 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 @@ -328,6 +324,7 @@ def heartbeat

heartbeat_to_file

sync_config if config_out_of_date?
process_messages_from_server unless MiqEnvironment::Command.is_podified?

@last_hb = now
Expand All @@ -354,23 +351,19 @@ def heartbeat_to_file(timeout = nil)

timeout ||= worker_settings[:heartbeat_timeout] || Workers::MiqDefaults.heartbeat_timeout
File.write(@worker.heartbeat_file, (Time.now.utc + timeout).to_s)

get_messages.each { |msg, *args| process_message(msg, *args) }
end

def get_messages
messages = []
def config_out_of_date?
@my_last_config_change ||= Time.now.utc

last_config_change = server_last_change(:last_config_change)
if last_config_change && last_config_change > @my_last_config_change
_log.info("#{log_prefix} Configuration has changed, New TS: #{last_config_change}, Old TS: #{@my_last_config_change}")
messages << ["sync_config"]

@my_last_config_change = last_config_change
return true
end

messages
false
end

def key_store
Expand Down

0 comments on commit efb4593

Please sign in to comment.