-
Notifications
You must be signed in to change notification settings - Fork 900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Always use file based heartbeat #19666
Changes from all commits
849eec9
20f9cc5
5df4609
9c4d135
d594f36
7a0d6b9
010055a
fe52aad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -238,12 +238,6 @@ 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 | ||
# Sync roles | ||
@active_roles = MiqServer.my_active_roles(true) | ||
|
@@ -326,7 +320,16 @@ def heartbeat | |
# Heartbeats can be expensive, so do them only when needed | ||
return if @last_hb.kind_of?(Time) && (@last_hb + worker_settings[:heartbeat_freq]) >= now | ||
|
||
ENV["WORKER_HEARTBEAT_METHOD"] == "file" ? heartbeat_to_file : heartbeat_to_drb | ||
heartbeat_to_file | ||
|
||
if config_out_of_date? | ||
_log.info("#{log_prefix} Synchronizing configuration...") | ||
sync_config | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lol, there it is. Ignore my above question. |
||
_log.info("#{log_prefix} Synchronizing configuration complete...") | ||
end | ||
|
||
process_messages_from_server unless MiqEnvironment::Command.is_podified? | ||
|
||
@last_hb = now | ||
do_heartbeat_work | ||
rescue SystemExit, SignalException | ||
|
@@ -335,41 +338,35 @@ def heartbeat | |
do_exit("Error heartbeating because #{err.class.name}: #{err.message}\n#{err.backtrace.join('\n')}", 1) | ||
end | ||
|
||
def heartbeat_to_drb | ||
# Disable heartbeat check. Useful if a worker is running in isolation | ||
# without the oversight of MiqServer::WorkerManagement | ||
return if skip_heartbeat? | ||
|
||
def process_messages_from_server | ||
worker_monitor_drb.register_worker(@worker.pid, @worker.class.name, @worker.queue_name) | ||
worker_monitor_drb.update_worker_last_heartbeat(@worker.pid) | ||
|
||
worker_monitor_drb.worker_get_messages(@worker.pid).each do |msg, *args| | ||
process_message(msg, *args) | ||
end | ||
rescue DRb::DRbError => err | ||
do_exit("Error heartbeating to MiqServer because #{err.class.name}: #{err.message}", 1) | ||
do_exit("Error processing messages from MiqServer because #{err.class.name}: #{err.message}", 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if this PR is about removing DRb-based heartbeating, why do we have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method in particular is not for heartbeat. This fetches messages set for the worker in the The vim broker is the only worker that still uses this functionality (previously it was also used for config sync and stopping workers), so this can all be removed once the vim broker is gone. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To clarify, processing messages and heartbeating are two different operations that we happen to execute at the same time. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for the clarification @carbonin |
||
end | ||
|
||
def heartbeat_to_file(timeout = nil) | ||
# Disable heartbeat check. Useful if a worker is running in isolation | ||
# without the oversight of MiqServer::WorkerManagement | ||
return if skip_heartbeat? | ||
|
||
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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😮 Awesome
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
though, how do the worker know when config is changed now?