Commit f92d8890 authored by Leigh B Stoller's avatar Leigh B Stoller

Fixes to prevent the expire daemon from shutting down a slice over and

over and over. Add a flag to geni_slices, to indicate the slice is
down.
parent 51735e2d
...@@ -62,6 +62,7 @@ CREATE TABLE `geni_slices` ( ...@@ -62,6 +62,7 @@ CREATE TABLE `geni_slices` (
`registered` tinyint(1) NOT NULL default '0', `registered` tinyint(1) NOT NULL default '0',
`needsfirewall` tinyint(1) NOT NULL default '0', `needsfirewall` tinyint(1) NOT NULL default '0',
`isplaceholder` tinyint(1) NOT NULL default '0', `isplaceholder` tinyint(1) NOT NULL default '0',
`isshutdown` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`idx`), PRIMARY KEY (`idx`),
UNIQUE KEY `hrn` (`hrn`), UNIQUE KEY `hrn` (`hrn`),
UNIQUE KEY `uuid` (`uuid`) UNIQUE KEY `uuid` (`uuid`)
......
...@@ -255,9 +255,6 @@ sub Resolve($) ...@@ -255,9 +255,6 @@ sub Resolve($)
return GeniResponse->MalformedArgsResponse(); return GeniResponse->MalformedArgsResponse();
} }
$type = lc($type); $type = lc($type);
if (! defined($cred)) {
return GeniResponse->MalformedArgsResponse();
}
my $lookup_token = ($urn || $uuid || $hrn); my $lookup_token = ($urn || $uuid || $hrn);
my $authority = GeniAuthority->Lookup($ENV{'MYURN'}); my $authority = GeniAuthority->Lookup($ENV{'MYURN'});
...@@ -265,14 +262,25 @@ sub Resolve($) ...@@ -265,14 +262,25 @@ sub Resolve($)
print STDERR "Could not find local authority object\n"; print STDERR "Could not find local authority object\n";
return GeniResponse->Create(GENIRESPONSE_ERROR); return GeniResponse->Create(GENIRESPONSE_ERROR);
} }
my $credential = CheckCredential($cred, $authority);
return $credential #
if (GeniResponse::IsResponse($credential)); # We allow any valid user without a credential, to resolve
# authorities. Helpful for Flack.
#
if (! defined($cred) &&
! ($type eq "cm" || $type eq "am" || $type eq "sa")) {
return GeniResponse->MalformedArgsResponse();
}
else {
my $credential = CheckCredential($cred, $authority);
return $credential
if (GeniResponse::IsResponse($credential));
$credential->HasPrivilege( "authority" ) or $credential->HasPrivilege( "authority" ) or
$credential->HasPrivilege( "resolve" ) or $credential->HasPrivilege( "resolve" ) or
return GeniResponse->Create( GENIRESPONSE_FORBIDDEN, undef, return GeniResponse->Create( GENIRESPONSE_FORBIDDEN, undef,
"Insufficient privilege" ); "Insufficient privilege" );
}
if ($type eq "user") { if ($type eq "user") {
my $user = GeniUser->Lookup($lookup_token); my $user = GeniUser->Lookup($lookup_token);
......
...@@ -4708,6 +4708,7 @@ sub CleanupDeadSlice($;$) ...@@ -4708,6 +4708,7 @@ sub CleanupDeadSlice($;$)
if (system("$NAMEDSETUP")) { if (system("$NAMEDSETUP")) {
print STDERR "$NAMEDSETUP failed\n"; print STDERR "$NAMEDSETUP failed\n";
} }
$experiment->SetState(EXPTSTATE_SWAPPED());
} }
return 0 return 0
......
...@@ -268,6 +268,7 @@ sub creator_uuid($) { return field($_[0], "creator_uuid"); } ...@@ -268,6 +268,7 @@ sub creator_uuid($) { return field($_[0], "creator_uuid"); }
sub creator_urn($) { return field($_[0], "creator_urn"); } sub creator_urn($) { return field($_[0], "creator_urn"); }
sub created($) { return field($_[0], "created"); } sub created($) { return field($_[0], "created"); }
sub shutdown($) { return field($_[0], "shutdown"); } sub shutdown($) { return field($_[0], "shutdown"); }
sub isshutdown($) { return field($_[0], "isshutdown"); }
sub expires($) { return field($_[0], "expires"); } sub expires($) { return field($_[0], "expires"); }
sub sa_uuid($) { return field($_[0], "sa_uuid"); } sub sa_uuid($) { return field($_[0], "sa_uuid"); }
sub exptidx($) { return field($_[0], "exptidx"); } sub exptidx($) { return field($_[0], "exptidx"); }
...@@ -828,15 +829,19 @@ sub SetShutdown($$) ...@@ -828,15 +829,19 @@ sub SetShutdown($$)
else { else {
$when = "NULL"; $when = "NULL";
} }
#
# Always clear isshutdown so that expire_daemon knows of change.
#
my $query_result = my $query_result =
DBQueryWarn("update geni_slices set shutdown=$when " . DBQueryWarn("update geni_slices set shutdown=$when, isshutdown=0 " .
"where uuid='$uuid'"); "where uuid='$uuid'");
return -1 return -1
if (!$query_result); if (!$query_result);
# XXX Wrong format, but harmless. # XXX Wrong format, but harmless.
$self->{'SLICE'}->{'shutdown'} = ($shutdown ? time() : undef); $self->{'SLICE'}->{'shutdown'} = ($shutdown ? time() : undef);
$self->{'SLICE'}->{'isshutdown'} = 0;
return 0; return 0;
} }
...@@ -906,6 +911,27 @@ sub SetRegisteredFlag($$) ...@@ -906,6 +911,27 @@ sub SetRegisteredFlag($$)
return 0; return 0;
} }
#
# Set the isshutdown field.
#
sub SetShutdownFlag($$)
{
my ($self, $isshutdown) = @_;
my $uuid = $self->uuid();
$isshutdown = ($isshutdown ? 1 : 0);
my $query_result =
DBQueryWarn("update geni_slices set isshutdown='$isshutdown' " .
"where uuid='$uuid'");
return -1
if (!$query_result);
$self->{'SLICE'}->{'isshutdown'} = $isshutdown;
return 0;
}
# #
# Convert from placeholder to real slice. Caller will have it locked. # Convert from placeholder to real slice. Caller will have it locked.
# #
......
...@@ -212,7 +212,7 @@ sub WarnSlices() ...@@ -212,7 +212,7 @@ sub WarnSlices()
# #
# If expiration is greater then 24 hours out, skip. # If expiration is greater then 24 hours out, skip.
# #
print STDERR "$stamp, $created, $grace, ". time() . "\n"; #print STDERR "$stamp, $created, $grace, ". time() . "\n";
if ($stamp > time() + $grace) { if ($stamp > time() + $grace) {
delete($expires{$idx}); delete($expires{$idx});
...@@ -399,7 +399,7 @@ sub ShutdownSlices() ...@@ -399,7 +399,7 @@ sub ShutdownSlices()
{ {
my $query_result = my $query_result =
GeniDB::DBQueryWarn("select idx from geni_slices ". GeniDB::DBQueryWarn("select idx from geni_slices ".
"where shutdown is not null"); "where shutdown is not null and isshutdown=0");
while (my ($idx) = $query_result->fetchrow_array()) { while (my ($idx) = $query_result->fetchrow_array()) {
my $slice = GeniSlice->Lookup($idx); my $slice = GeniSlice->Lookup($idx);
...@@ -414,14 +414,14 @@ sub ShutdownSlices() ...@@ -414,14 +414,14 @@ sub ShutdownSlices()
} }
# #
# This will get called everytime, but CleanupDeadSlice does # The isshutdown flag avoids churning the system.
# not actually do anything if there are no slivers.
# #
if (GeniCM::CleanupDeadSlice($slice, 0) != 0) { if (GeniCM::CleanupDeadSlice($slice, 0) != 0) {
print STDERR "Could not shutdown $slice\n"; print STDERR "Could not shutdown $slice\n";
SENDMAIL($TBOPS, "Could not shutdown slice", SENDMAIL($TBOPS, "Could not shutdown slice",
"Could not shutdown slice $slice"); "Could not shutdown slice $slice");
} }
$slice->SetShutdownFlag(1);
$slice->UnLock(); $slice->UnLock();
skip: skip:
$slice->Flush() $slice->Flush()
......
#
# Add isshutdown slot to geni_slices
#
use strict;
use GeniDB;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
DBSetDefault($dbhandle);
if (!DBSlotExists("geni_slices", "isshutdown")) {
DBQueryFatal("alter table geni_slices ".
" add `isshutdown` tinyint(1) NOT NULL default '0'");
}
return 0;
}
1;
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