Commit 27ac0cc3 authored by Leigh Stoller's avatar Leigh Stoller

When sending status events, use the timestamp in the database instead

of the current time. Basically using a sequence number now.
parent e450819b
......@@ -301,6 +301,7 @@ sub speaksfor_uuid($) { return field($_[0], "speaksfor_uuid"); }
sub speaksfor_urn($) { return field($_[0], "speaksfor_urn"); }
sub status($) { return field($_[0], "status"); }
sub state($) { return field($_[0], "state"); }
sub status_state_timestamp($) { return field($_[0], "status_state_timestamp"); }
sub boot_failure($) { return field($_[0], "boot_failure"); }
sub ErrorLog($) { return field($_[0], "errorlog"); }
sub cert($) { return GetCertificate($_[0])->cert(); }
......@@ -659,7 +660,8 @@ sub SendStatusEvent($)
my $blob = {
"state" => $self->state(),
"status" => $self->status(),
"utc" => time(),
# Fall back to current time if no timestamp yet.
"utc" => $self->status_state_timestamp() || time(),
};
GeniEvent->SendEvent({"type" => "SLICESTATUS",
"slice" => $slice->urn(),
......
......@@ -312,6 +312,7 @@ sub aggregate_uuid($) { return field($_[0], "aggregate_uuid"); }
sub rspec_string($) { return field($_[0], "rspec_string"); }
sub status($) { return field($_[0], "status"); }
sub state($) { return field($_[0], "state"); }
sub status_state_timestamp($) { return field($_[0], "status_state_timestamp"); }
sub ErrorLog($) { return field($_[0], "errorlog"); }
sub cert($) { return GetCertificate($_[0])->cert(); }
sub rspec($) { return $_[0]->{'RSPEC'}; }
......@@ -1647,18 +1648,36 @@ sub GenerateStatusBlob($)
my $state = $self->state();
my $status = $self->status();
my $nickname = $self->nickname() || "";
# Fall back to current time if no timestamp yet.
my $utc = $self->status_state_timestamp() || time();
my $node = Node->LookupSync($resource_id);
if (!defined($node)) {
print STDERR "Could not map node $resource_id to its object\n";
return undef;
}
my ($nodestatus) = $node->GetStatus() || "unknown";
my ($nodestatus,$nodestatus_timestamp) = $node->GetStatus();
if (!defined($nodestatus)) {
$nodestatus = "unknown";
$nodestatus_timestamp = 0;
}
my $rawstate = $node->eventstate();
my $rawstate_timestamp = $node->state_timestamp();
# New is the same as stopped. Separate state is handy.
$state = "stopped"
if ($state eq "new");
#
# So we have a bunch of timestamps for various bits of state.
# Not much atomicity, but I think we are okay. Use the most
# recent timestamp, else current time.
#
$utc = $nodestatus_timestamp
if ($nodestatus_timestamp > $utc);
$utc = $rawstate_timestamp
if ($rawstate_timestamp > $utc);
my $blob = {
"component_urn" => $resource_id,
"client_id" => $nickname,
......@@ -1666,9 +1685,9 @@ sub GenerateStatusBlob($)
"status" => $status,
# We do not put this in unless its for SliverStatus. Too big.
"error" => "",
"rawstate" => $node->eventstate(),
"rawstate" => $rawstate,
"nodestatus" => $nodestatus,
"utc" => time(),
"utc" => $utc,
};
#
......
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