Commit 9326c43b authored by Leigh B Stoller's avatar Leigh B Stoller

Add a change for admission control; set the previously unused

expt_expires slot in the experiments table whenever we set the slice
expiration time. In addition, do this in GetTicket() so that the
mapper sees the proper expiration time; we do not set the slice
expiration until the ticket is redeemed, and this throws off admission
control.
parent d47cf716
#!/usr/bin/perl -wT
#
# Copyright (c) 2005-2016 University of Utah and the Flux Group.
# Copyright (c) 2005-2017 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -1351,6 +1351,38 @@ sub SetBatchMode($$) {
return ($success ? 0 : -1);
}
#
# We use this for admission control of geni slices.
#
sub SetExpiration($$)
{
my ($self, $expires) = @_;
my $idx = $self->idx();
if ($expires =~ /^\d+$/) {
$expires = "FROM_UNIXTIME($expires)";
}
else {
$expires = "'$expires'";
}
my $query_result =
DBQueryWarn("update experiments set expt_expires=$expires " .
"where idx='$idx'");
return -1
if (!$query_result);
# Has to be in the correct format.
$query_result =
DBQueryWarn("select expt_expires from experiments ".
"where idx='$idx'");
return -1
if (!$query_result || !$query_result->numrows);
($expires) = $query_result->fetchrow_array();
$self->{'EXPT'}->{'expt_expires'} = $expires;
return 0;
}
#
# Generic function to look up some table values given a set of desired
# fields and some conditions. Pretty simple, not widely useful, but it
......
......@@ -722,6 +722,17 @@ sub GetTicketAuxAux($$$$$$$$$$$)
$slice_experiment = undef;
goto bad;
}
#
# Mark the expires slot in the experiment, for admission control
# during the mapper run.
#
if ($slice_experiment->SetExpiration(defined($expires) ? $expires :
$slice->expires())) {
$response = GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"set experiment expiration");
print STDERR "Could not set experiment expiration\n";
goto bad;
}
my $realuser = FlipToUser($slice, $user);
if (! (defined($realuser) && $realuser)) {
$response = GeniResponse->Create(GENIRESPONSE_ERROR, undef,
......@@ -7587,9 +7598,20 @@ sub SetSliceExpiration($$$$@)
goto bad;
}
}
if (!$checkonly && $slice->SetExpiration($when) != 0) {
$message = "could not set expiration time";
goto bad;
if (!$checkonly) {
if ($slice->SetExpiration($when) != 0) {
$message = "could not set expiration time";
goto bad;
}
#
# Mark the expires slot in the experiment, for admission control
# during the mapper run.
#
if (defined($slice_experiment) &&
$slice_experiment->SetExpiration($when)) {
$message = "could not set slice experiment expiration time";
goto bad;
}
}
return 0;
......
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