Commit e9a222db authored by Mike Hibler's avatar Mike Hibler
Browse files

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