Commit 008887d1 authored by Leigh Stoller's avatar Leigh Stoller

Store the maximum allowed extension with the extension request info so

we can infer if an extension request has been limited by the reservation
schedule.
parent 6d3de957
......@@ -141,6 +141,7 @@ sub DoCheckAutoApprove();
sub CheckAutoApprove($$);
sub CheckReservationInternal($$$);
sub DoMaxExtension();
sub DoMaxExtensionInternal($$$);
sub DoApplyExtensionPolicy();
sub WriteCredentials();
sub StartMonitor();
......@@ -1382,6 +1383,7 @@ sub DoExtend()
my $granted = 0;
my $needapproval = 0;
my $autoapprove_info;
my $maxextension;
my $message;
my $reason;
my $errmsg;
......@@ -1391,7 +1393,7 @@ sub DoExtend()
usage()
if (!@ARGV);
my $optlist = "m:f:hF";
my $optlist = "m:f:hFe:";
my %options = ();
if (! getopts($optlist, \%options)) {
usage();
......@@ -1424,6 +1426,14 @@ sub DoExtend()
}
close(MSG);
}
if (defined($options{"e"})) {
$maxextension = str2time($options{"e"});
if (!$maxextension) {
$errmsg = "Illegal max extension date";
$errcode = -1;
goto bad;
}
}
#
# Lock the slice in case it is doing something else, like taking
......@@ -1710,6 +1720,9 @@ sub DoExtend()
if ($needapproval) {
$extensionargs->{"needapproval"} = 1;
}
if (defined($maxextension)) {
$extensionargs->{"maxextension"} = TBDateStringLocal($maxextension);
}
if (defined($message)) {
$extensionargs->{"message"} = $message;
}
......@@ -2062,6 +2075,34 @@ sub CheckReservationInternal($$$)
#
sub DoMaxExtension()
{
my $slice = $instance->GetGeniSlice();
my $result;
my $errmsg;
my $errcode = DoMaxExtensionInternal($instance, \$result, 0);
if ($errcode) {
$errmsg = $result;
goto bad;
}
if ($debug) {
print "Max extension: " . TBDateStringLocal($result) . "\n";
}
if (defined($webtask)) {
$webtask->MaxExtension(TBDateStringGMT($result));
$webtask->Exited(0);
}
exit(0);
bad:
if (defined($webtask)) {
$webtask->output($errmsg) if (defined($errmsg));
$webtask->Exited($errcode);
}
exit($errcode);
}
sub DoMaxExtensionInternal($$$)
{
my ($instance, $prval, $nolock) = @_;
my $slice = $instance->GetGeniSlice();
my $maxinfo;
my $errmsg;
......@@ -2077,9 +2118,9 @@ sub DoMaxExtension()
# No need to lock if only one aggregate, we do not use the per-agg
# web tasks down in CallAggregateMethod(). Hack, needs more thought.
#
if (scalar(@aggregates) > 1 && $slice->WaitForLock(15)) {
if (!$nolock && scalar(@aggregates) > 1 && $slice->WaitForLock(15)) {
print STDERR "Experiment is busy, cannot lock it. Try again later.\n";
exit(GENIRESPONSE_BUSY);
return GENIRESPONSE_BUSY;
}
my $errcode = CallAggregateMethod("MaxExtension", \$maxinfo, @aggregates);
if ($errcode) {
......@@ -2099,24 +2140,15 @@ sub DoMaxExtension()
$newmax = $max
if ($max < $newmax);
}
if ($debug) {
print "Max extension: " . TBDateStringLocal($newmax) . "\n";
}
if (defined($webtask)) {
$webtask->MaxExtension(TBDateStringGMT($newmax));
$webtask->Exited(0);
}
$slice->UnLock()
if (scalar(@aggregates) > 1);
exit(0);
if (scalar(@aggregates) > 1 && !$nolock);
$$prval = $newmax;
return 0;
bad:
$slice->UnLock()
if (scalar(@aggregates) > 1);
if (defined($webtask)) {
$webtask->output($errmsg);
$webtask->Exited($errcode);
}
exit($errcode);
if (scalar(@aggregates) > 1 && !$nolock);
return $errcode;
}
#
......
......@@ -20,6 +20,7 @@ window.ShowExtendModal = (function()
var howlong = 24; // Number of hours being requested.
var SLIDERLIMIT= 84 * 24;
var extension_info = null;
var maxextend_date = null;
var physnode_count = 0;
var physnode_hours = 0;
......@@ -429,20 +430,25 @@ window.ShowExtendModal = (function()
// Save this for next time we show the modal.
extension_info.extension_reason = reason;
sup.HideModal('#extend_modal');
sup.ShowModal("#waitwait-modal");
var xmlthing = sup.CallServerMethod(null,
"status",
"RequestExtension",
{"uuid" : uuid,
"howlong": howlong,
"reason" : reason});
xmlthing.done(function(json) {
console.info(json.value);
sup.HideModal("#waitwait-modal", function () {
callback(json);
var args = {"uuid" : uuid,
"howlong": howlong,
"reason" : reason};
// Pass through to store with the extension info; harmless if
// the user browser messes with it.
if (maxextend_date) {
args["maxextension"] = maxextend_date;
}
sup.HideModal('#extend_modal', function () {
sup.ShowModal("#waitwait-modal");
var xmlthing = sup.CallServerMethod(null, "status",
"RequestExtension", args);
xmlthing.done(function(json) {
console.info(json.value);
sup.HideModal("#waitwait-modal", function () {
callback(json);
});
return;
});
return;
});
}
......@@ -551,6 +557,7 @@ window.ShowExtendModal = (function()
}
else {
later = new Date(json.value);
maxextend_date = json.value;
}
console.info("Max extension date:", later);
......
......@@ -373,6 +373,13 @@ function Do_RequestExtension()
SPITAJAX_ERROR(1, "Invalid characters in hours");
goto bad;
}
if (isset($ajax_args["maxextension"]) && $ajax_args["maxextension"] != "") {
$maxextension = $ajax_args["maxextension"];
if (!strtotime($maxextension)) {
SPITAJAX_ERROR(1, "Invalid max extension date");
goto bad;
}
}
if (ISADMIN()) {
if (isset($ajax_args["reason"]) && $ajax_args["reason"] != "") {
$reason = $ajax_args["reason"];
......@@ -403,6 +410,7 @@ function Do_RequestExtension()
"webmanage_instance -t " . $webtask->task_id() . " -- ".
" extend $uuid " .
(isset($filename) ? "-f $filename " : "").
(isset($maxextension) ? "-e '$maxextension' " : "").
($force ? "-F " : "") . "'$wanted'",
SUEXEC_ACTION_IGNORE);
$webtask->Refresh();
......
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