Commit d71cb327 authored by Jonathon Duerig's avatar Jonathon Duerig

Add a boot_error global flag for GENI aggregates

parent f1a84950
...@@ -123,6 +123,7 @@ CREATE TABLE `geni_aggregates` ( ...@@ -123,6 +123,7 @@ CREATE TABLE `geni_aggregates` (
`status` varchar(16) NOT NULL default 'created', `status` varchar(16) NOT NULL default 'created',
`state` varchar(16) NOT NULL default 'stopped', `state` varchar(16) NOT NULL default 'stopped',
`errorlog` text, `errorlog` text,
`boot_failure` tinyint(1) default '0',
PRIMARY KEY (`idx`), PRIMARY KEY (`idx`),
UNIQUE KEY `uuid` (`uuid`), UNIQUE KEY `uuid` (`uuid`),
INDEX `slice_uuid` (`slice_uuid`) INDEX `slice_uuid` (`slice_uuid`)
......
...@@ -279,6 +279,7 @@ sub speaksfor_uuid($) { return field($_[0], "speaksfor_uuid"); } ...@@ -279,6 +279,7 @@ sub speaksfor_uuid($) { return field($_[0], "speaksfor_uuid"); }
sub speaksfor_urn($) { return field($_[0], "speaksfor_urn"); } sub speaksfor_urn($) { return field($_[0], "speaksfor_urn"); }
sub status($) { return field($_[0], "status"); } sub status($) { return field($_[0], "status"); }
sub state($) { return field($_[0], "state"); } sub state($) { return field($_[0], "state"); }
sub boot_failed($) { return field($_[0], "boot_failed"); }
sub ErrorLog($) { return field($_[0], "errorlog"); } sub ErrorLog($) { return field($_[0], "errorlog"); }
sub cert($) { return GetCertificate($_[0])->cert(); } sub cert($) { return GetCertificate($_[0])->cert(); }
# Watch for aggregates that no longer get a certificate. # Watch for aggregates that no longer get a certificate.
...@@ -615,6 +616,34 @@ sub SetErrorLog($$) ...@@ -615,6 +616,34 @@ sub SetErrorLog($$)
return 0; return 0;
} }
sub SetBootFailure($)
{
return undef
if (! ref($self));
my $idx = $self->idx();
return -1
if (!DBQueryWarn("update geni_aggregates set ".
" boot_failure='1' ".
"where idx='$idx'"));
return 0;
}
sub ClearBootFailure($)
{
return undef
if (! ref($self));
my $idx = $self->idx();
return -1
if (!DBQueryWarn("update geni_aggregates set ".
" boot_failure='0' ".
"where idx='$idx'"));
return 0;
}
# #
# Set the registered datetime for the aggregate # Set the registered datetime for the aggregate
# #
...@@ -837,6 +866,7 @@ sub ProcessManifest($$) ...@@ -837,6 +866,7 @@ sub ProcessManifest($$)
sub Start($$$) sub Start($$$)
{ {
my ($self, $version, $restart) = @_; my ($self, $version, $restart) = @_;
$self->ClearBootFailure();
my $msg = "Internal Error: "; my $msg = "Internal Error: ";
require Lan; require Lan;
require OSinfo; require OSinfo;
...@@ -1431,6 +1461,7 @@ sub Start($$$) ...@@ -1431,6 +1461,7 @@ sub Start($$$)
return 0; return 0;
bad: bad:
$self->SetBootFailure();
if (defined($msg)) { if (defined($msg)) {
$self->SetErrorLog($msg); $self->SetErrorLog($msg);
print STDERR "$msg\n"; print STDERR "$msg\n";
...@@ -1710,6 +1741,7 @@ sub WaitForNodes($@) ...@@ -1710,6 +1741,7 @@ sub WaitForNodes($@)
sub Stop($$) sub Stop($$)
{ {
my ($self, $version) = @_; my ($self, $version) = @_;
$self->ClearBootFailure();
my $msg = "Internal Error: "; my $msg = "Internal Error: ";
return -1 return -1
...@@ -1842,6 +1874,7 @@ sub Stop($$) ...@@ -1842,6 +1874,7 @@ sub Stop($$)
return 0; return 0;
bad: bad:
$self->SetBootFailure();
if (defined($msg)) { if (defined($msg)) {
$self->SetErrorLog($msg); $self->SetErrorLog($msg);
print STDERR "$msg\n"; print STDERR "$msg\n";
...@@ -1938,6 +1971,7 @@ sub ComputeState($) ...@@ -1938,6 +1971,7 @@ sub ComputeState($)
my $failed = 0; my $failed = 0;
my $changing= 0; my $changing= 0;
my $count = 0; my $count = 0;
my $boot_failed = $self->boot_failed();
return -1 return -1
if (! ref($self)); if (! ref($self));
...@@ -2004,7 +2038,10 @@ sub ComputeState($) ...@@ -2004,7 +2038,10 @@ sub ComputeState($)
} }
} }
if ($stopped == $count) { if ($boot_failed == 1) {
$self->SetState("failed");
}
elsif ($stopped == $count) {
$self->SetState("stopped"); $self->SetState("stopped");
} }
elsif ($started == $count) { elsif ($started == $count) {
......
#
# Changes for quick containers.
#
use strict;
use GeniDB;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
DBSetDefault($dbhandle);
if (!DBSlotExists("geni_aggregates", "boot_failure")) {
DBQueryFatal("alter table geni_aggregates add ".
" `boot_failure` TINYINT(1) default 0 ");
}
return 0;
}
1;
# Local Variables:
# mode:perl
# End:
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