Commit 1e5966ad authored by Leigh Stoller's avatar Leigh Stoller

Fix discrepancy between TBSetNodeEventState() and Node->SetEventState();

both send an event for stated to pick up, but the later also immediately
updates the DB while the former does not. This can lead to lost or out
of sync stated events.
parent f7927a3a
......@@ -2297,11 +2297,13 @@ sub GetBootLog($$)
}
#
# Set event state for a node.
# Set event state for a node. Note that we do not change the DB here,
# but let stated do that. If stated dies ...
#
sub SetEventState($$)
sub SetEventState($$;$)
{
my ($self, $state) = @_;
my ($self, $state, $fatal) = @_;
my $rval;
require event;
# Must be a real reference.
......@@ -2310,17 +2312,19 @@ sub SetEventState($$)
my $node_id = $self->node_id();
#
# If using the event system, we send out an event for the state daemon to
# pick up. Otherwise, we just set the state in the database ourselves
#
return event::EventSendFatal(objtype => TBDB_TBEVENT_NODESTATE,
objname => $node_id,
eventtype => $state,
host => $BOSSNODE);
return $self->Update({"eventstate" => $state,
"state_timestamp" => time()});
if (!defined($fatal) || $fatal) {
$rval = event::EventSendFatal(objtype => TBDB_TBEVENT_NODESTATE,
objname => $node_id,
eventtype => $state,
host => $BOSSNODE);
}
else {
$rval = event::EventSendWarn(objtype => TBDB_TBEVENT_NODESTATE,
objname => $node_id,
eventtype => $state,
host => $BOSSNODE);
}
return ($rval == 1 ? 0 : -1);
}
sub ResetStartStatus($)
......
......@@ -940,24 +940,10 @@ sub TBSetNodeEventState($$;$)
{
my ($node, $state, $fatal) = @_;
#
# If using the event system, we send out an event for the state daemon to
# pick up. Otherwise, we just set the state in the database ourselves
#
require event;
if (!defined($fatal) || $fatal) {
return event::EventSendFatal(objtype => TBDB_TBEVENT_NODESTATE,
objname => $node,
eventtype => $state,
host => $BOSSNODE);
}
else {
return event::EventSendWarn(objtype => TBDB_TBEVENT_NODESTATE,
objname => $node,
eventtype => $state,
host => $BOSSNODE);
if (!ref($node)) {
$node = LocalNodeLookup($node);
}
return $node->SetEventState($state, $fatal);
}
#
......
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