Commit b0229ae9 authored by Mac Newbold's avatar Mac Newbold

Check when we hit BOOTING that the opmode for the node's osid is the same

as the op_mode it is currently running. If not, force it and send mail.

This fixes the "stuck-in-reloading" phenomenon we occasionally see when
the states get messed up. Now anytime it loads PXEFRISBEE it should force
the mode to RELOAD, and it will stop reloading the first time it hits
parent c6af80b3
......@@ -412,9 +412,22 @@ sub stateTransition($$) {
# Check if this is TBDB_NODESTATE_BOOTING , which has actions
if ($newstate eq TBDB_NODESTATE_BOOTING) {
my $osid = TBBootWhat($node,$debug);
info("$node: Current OS is '$osid'\n");
my $os_op_mode = os_opmode($osid);
info("$node: Current OS is '$osid', OS mode is '$os_op_mode'\n");
DBQueryFatal("UPDATE nodes SET osid='$osid' WHERE node_id='$node'");
if ($os_op_mode ne $mode) {
my $str = "Node $node is running OS '$osid' but was not in ".
"mode '$os_op_mode'!\n";
if ($os_op_mode ne "") {
DBQueryFatal("UPDATE nodes SET op_mode='$os_op_mode', ".
"op_mode_timestamp=unix_timestamp(now()) ".
"WHERE node_id='$node'");
$nodes{$node}{mode} = $os_op_mode;
$nodes{$node}{mode_timestamp} = $now;
$str .= "Forced op_mode to '$os_op_mode'.\n";
......@@ -746,6 +759,17 @@ sub handleChild() {
return 0;
sub os_opmode() {
my $osid = shift || "";
my $cmd = "select op_mode from os_info where osid='$osid';";
my $q = DBQueryFatal($cmd);
if ($q->numrows() < 1) { return ""; }
my @r = $q->fetchrow_array();
my $opmode=$r[0];
debug("OpMode for '$osid' is '$opmode'\n");
if (defined($opmode) && $opmode ne "") { return $opmode; }
return "";
sub debug(@) {
if ($debug) { print @_; }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment