Browse files

Added a new file to the Microkernel that is used to store whether or …

…not the Microkernel controller is checking in for the first time. This change makes it possible for the Razor server to determine whether or not it should force a registration on first boot, even if the node has checked in more recently than the "register_timeout" (allowing for the Razor server to pick up configuration changes on the node that may have required a reboot of the node but that didn't take too long, so the time between checkins doesn't exceed that "register_timeout" value).
  • Loading branch information...
Tom McSweeney
Tom McSweeney committed May 17, 2012
1 parent a8ceda7 commit 38293edc495d637d3c6a8c2089bb7749c1b80d27
Showing with 31 additions and 1 deletion.
  1. +30 −1 rz_mk_control_server.rb
  2. +1 −0 tmp/first_checkin.yaml
@@ -94,6 +94,29 @@ def load_tcl_extensions(tce_install_list_uri, tce_mirror_uri, force_reinstall =
# file used to track whether or not a node has already checked in
# at least once (the first time through, this file will contain
# a true value, after that the value in this file will be false)
FIRST_CHECKIN_STATE_FILENAME = "/tmp/first_checkin.yaml"
# checks to see if this is the first checkin being made by this node
# since it was booted up
def is_first_checkin?
first_checkin_flag = false, 'r') { |file|
first_checkin_flag = YAML::load(file)
# used to set the flag in the first checkin file to false
def first_checkin_performed
first_checkin_flag = false, 'w') { |file|
YAML::dump(first_checkin_flag, file)
# set up a global variable that will be used in the RazorMicrokernel::Logging mixin
# to determine where to place the log messages from this script
RZ_MK_LOG_PATH = "/var/log/rz_mk_controller.log"
@@ -176,7 +199,9 @@ def load_tcl_extensions(tce_install_list_uri, tce_mirror_uri, force_reinstall = "Sleeping for #{rand_secs} seconds"
# parameters used for checkin process
idle = 'idle'
is_first_checkin = is_first_checkin?
# and enter the main event-handling loop
loop do
@@ -197,7 +222,8 @@ def load_tcl_extensions(tce_install_list_uri, tce_mirror_uri, force_reinstall =
# FactManager. Currently, it includes a list of all of the network interfaces that
# have names that look like 'eth[0-9]+', but that may change down the line.
hw_id = fact_manager.get_hw_id_array
checkin_uri_string = checkin_uri + "?hw_id=#{hw_id}&last_state=#{idle}"
checkin_uri_string = checkin_uri +
"?hw_id=#{hw_id}&last_state=#{idle}&first_checkin=#{is_first_checkin}" "checkin_uri_string = #{checkin_uri_string}"
uri = URI checkin_uri_string
@@ -207,6 +233,9 @@ def load_tcl_extensions(tce_install_list_uri, tce_mirror_uri, force_reinstall =
response_hash = JSON.parse(response)
# if error code is 0 ()indicating a successful checkin), then process the response
if response_hash['errcode'] == 0 then
# save our state if this successful checkin was the first (after this call,
# the is_first_checkin? method should return false until the node is rebooted)
first_checkin_performed if is_first_checkin
# first, trigger appropriate action based on the command in the response
command = response_hash['response']['command_name']
if command == "acknowledge" then
@@ -0,0 +1 @@
--- true

0 comments on commit 38293ed

Please sign in to comment.