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` (
`registered` tinyint(1) NOT NULL default '0',
`needsfirewall` tinyint(1) NOT NULL default '0',
`isplaceholder` tinyint(1) NOT NULL default '0',
`isshutdown` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`idx`),
UNIQUE KEY `hrn` (`hrn`),
UNIQUE KEY `uuid` (`uuid`)
......
......@@ -255,9 +255,6 @@ sub Resolve($)
return GeniResponse->MalformedArgsResponse();
}
$type = lc($type);
if (! defined($cred)) {
return GeniResponse->MalformedArgsResponse();
}
my $lookup_token = ($urn || $uuid || $hrn);
my $authority = GeniAuthority->Lookup($ENV{'MYURN'});
......@@ -265,6 +262,16 @@ sub Resolve($)
print STDERR "Could not find local authority object\n";
return GeniResponse->Create(GENIRESPONSE_ERROR);
}
#
# 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));
......@@ -273,6 +280,7 @@ sub Resolve($)
$credential->HasPrivilege( "resolve" ) or
return GeniResponse->Create( GENIRESPONSE_FORBIDDEN, undef,
"Insufficient privilege" );
}
if ($type eq "user") {
my $user = GeniUser->Lookup($lookup_token);
......
......@@ -4708,6 +4708,7 @@ sub CleanupDeadSlice($;$)
if (system("$NAMEDSETUP")) {
print STDERR "$NAMEDSETUP failed\n";
}
$experiment->SetState(EXPTSTATE_SWAPPED());
}
return 0
......
......@@ -268,6 +268,7 @@ sub creator_uuid($) { return field($_[0], "creator_uuid"); }
sub creator_urn($) { return field($_[0], "creator_urn"); }
sub created($) { return field($_[0], "created"); }
sub shutdown($) { return field($_[0], "shutdown"); }
sub isshutdown($) { return field($_[0], "isshutdown"); }
sub expires($) { return field($_[0], "expires"); }
sub sa_uuid($) { return field($_[0], "sa_uuid"); }
sub exptidx($) { return field($_[0], "exptidx"); }
......@@ -828,8 +829,11 @@ sub SetShutdown($$)
else {
$when = "NULL";
}
#
# Always clear isshutdown so that expire_daemon knows of change.
#
my $query_result =
DBQueryWarn("update geni_slices set shutdown=$when " .
DBQueryWarn("update geni_slices set shutdown=$when, isshutdown=0 " .
"where uuid='$uuid'");
return -1
......@@ -837,6 +841,7 @@ sub SetShutdown($$)
# XXX Wrong format, but harmless.
$self->{'SLICE'}->{'shutdown'} = ($shutdown ? time() : undef);
$self->{'SLICE'}->{'isshutdown'} = 0;
return 0;
}
......@@ -906,6 +911,27 @@ sub SetRegisteredFlag($$)
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.
#
......
......@@ -212,7 +212,7 @@ sub WarnSlices()
#
# 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) {
delete($expires{$idx});
......@@ -399,7 +399,7 @@ sub ShutdownSlices()
{
my $query_result =
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()) {
my $slice = GeniSlice->Lookup($idx);
......@@ -414,14 +414,14 @@ sub ShutdownSlices()
}
#
# This will get called everytime, but CleanupDeadSlice does
# not actually do anything if there are no slivers.
# The isshutdown flag avoids churning the system.
#
if (GeniCM::CleanupDeadSlice($slice, 0) != 0) {
print STDERR "Could not shutdown $slice\n";
SENDMAIL($TBOPS, "Could not shutdown slice",
"Could not shutdown slice $slice");
}
$slice->SetShutdownFlag(1);
$slice->UnLock();
skip:
$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