Commit e9a222db authored by Mike Hibler's avatar Mike Hibler

Make sure nodes don't leave SECVIOLATION.

The logic was not quite right.  Also, don't send a SHUTDOWN event when
powering off a node.
parent 26416319
......@@ -637,14 +637,14 @@ sub stateTransition($$) {
$newstate = TBDB_NODESTATE_SECVIOLATION;
notify("Moving $node to $newstate because it's in $mode\n");
}
#
# And nodes that are in the SECVIOLATION state already are
# not allowed to leave!
#
elsif ($oldstate eq TBDB_NODESTATE_SECVIOLATION) {
$newstate = TBDB_NODESTATE_SECVIOLATION;
notify("$node tried to leave SECVIOLATION (to $newstate)\n");
}
}
#
# Nodes that are in the SECVIOLATION state are not allowed to leave!
#
if ($oldstate eq TBDB_NODESTATE_SECVIOLATION &&
$newstate ne TBDB_NODESTATE_SECVIOLATION) {
notify("$node tried to leave SECVIOLATION (to $newstate)\n");
$newstate = TBDB_NODESTATE_SECVIOLATION;
}
my $now = time();
......@@ -870,10 +870,16 @@ sub stateTransition($$) {
next;
};
(/^EMAILNOTIFY$/) && do {
my $msg = "$node entered state $mode/$newstate from " .
"$mode/$oldstate";
if ($newstate eq TBDB_NODESTATE_SECVIOLATION) {
$msg .= "\n\nNode $node has been powered off.\n" .
"You must address the cause of the violation ".
"and reset the eventstate before powering on.";
}
SENDMAIL($REALTBOPS,
"STATED: $node entered state $newstate",
"$node entered state $mode/$newstate from " .
"$mode/$oldstate",
$msg,
"Stated Daemon <".$TBOPS.">");
next;
};
......@@ -1187,10 +1193,13 @@ sub handleCommand($$;$$) {
$TBPOWEROFF => "off");
my $func = $funcmap{$command};
info("Sending power $func for nodes: $nodelist\n");
#
# Permissions were checked in order to send the message,
# so we don't need to do any fancy stuff here.
my $cmd = "$power $func $nodelist &";
# We do invoke with -e to prevent power from sending a
# further SHUTDOWN event.
#
my $cmd = "$power -e $func $nodelist &";
debug("$cmd\n");
system($cmd) and
notify("$params/$command: ".
......@@ -1693,4 +1702,3 @@ END {
# Restore $? in case one of the things I called changed it
$? = $stat;
}
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