Commit 53c94b3c authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Watch for locked experiment when trying to flip lockdown. Also add

missing handler for quarantine checkbox.
parent 62b31b3e
......@@ -3179,6 +3179,8 @@ sub DoLockdownInternal($$)
sub DoLockdown()
{
my $errmsg;
usage()
if (@ARGV != 2);
......@@ -3195,7 +3197,8 @@ sub DoLockdown()
fatal("No slice for instance");
}
if ($slice->Lock()) {
fatal("Experiment is busy, cannot lock it. Please try again later");
$errmsg = "Experiment is busy, cannot lock it. Please try again later";
goto bad;
}
if (DoLockdownInternal($setclr, $which)) {
$slice->UnLock();
......@@ -3203,11 +3206,21 @@ sub DoLockdown()
}
$slice->UnLock();
exit(0);
bad:
$slice->UnLock();
print STDERR $errmsg . "\n";
if (defined($webtask)) {
$webtask->output($errmsg);
$webtask->Exited(1);
}
exit(1);
}
sub DoPanic()
{
my $emsg;
my $errmsg;
my $errcode = -1;
usage()
if (@ARGV != 1);
......@@ -3221,7 +3234,9 @@ sub DoPanic()
fatal("No slice for instance");
}
if ($slice->Lock()) {
fatal("Experiment is busy, cannot lock it. Please try again later");
$errmsg = "Experiment is busy, cannot lock it. Please try again later";
$errcode = 1;
goto bad;
}
#
# And tell the backend clusters to Panic the slice.
......@@ -3247,7 +3262,7 @@ sub DoPanic()
if (ParRun({"maxwaittime" => 99999,
"maxchildren" => scalar(@agglist)},
\@return_codes, $coderef, @agglist)) {
$emsg = "Internal error calling Panic()";
$errmsg = "Internal error calling Panic()";
goto bad;
}
#
......@@ -3255,20 +3270,26 @@ sub DoPanic()
#
foreach my $code (@return_codes) {
if ($code) {
print STDERR "Some slivers could not be paniced";
$errmsg = "Some slivers could not be paniced";
goto bad;
}
}
if ($instance->SetPanic(($setclr eq "clear" ? 1 : 0))) {
$emsg = "Could not update instance panic flag";
$errmsg = "Could not update instance panic flag";
goto bad;
}
StartMonitorInternal();
$slice->UnLock();
exit(0);
bad:
$slice->UnLock();
exit(-1);
print STDERR $errmsg . "\n";
if (defined($webtask)) {
$webtask->output($errmsg);
$webtask->Exited($errcode);
}
exit($errcode);
}
#
......
......@@ -186,7 +186,11 @@ $(function ()
.change(function() {
DoLockdown("admin",
$(this).is(":checked"));
});
});
$('#quarantine-checkbox')
.change(function() {
DoQuarantine($(this).is(":checked"));
});
// This activates the popover subsystem.
$('[data-toggle="popover"]').popover({
trigger: 'hover',
......@@ -281,11 +285,25 @@ $(function ()
var action = (lockdown ? "set" : "clear");
var callback = function(json) {
sup.HideModal("#waitwait-modal");
if (json.code) {
alert("Failed to change lockdown: " + json.value);
sup.HideModal("#waitwait-modal", function () {
sup.SpitOops("oops",
"Lockdown failed: " + json.value);
if (lockdown) {
// Flip the checkbox back.
$('#' + which + '-lockdown-checkbox')
.prop("checked", false);
}
else {
// Flip the checkbox back.
$('#' + which + '-lockdown-checkbox')
.prop("checked", true);
}
});
return;
}
sup.HideModal("#waitwait-modal");
if (which == "admin") {
if (lockdown) {
$('#terminate-button').attr("disabled", "disabled");
......@@ -303,6 +321,41 @@ $(function ()
xmlthing.done(callback);
}
//
// Request panic mode set/clear.
//
function DoQuarantine(mode)
{
mode = (mode ? 1 : 0);
var callback = function(json) {
if (json.code) {
sup.HideModal('#waitwait-modal', function () {
sup.SpitOops("oops",
"Failed to change Quarantine mode: " +
json.value);
if (mode) {
// Flip the checkbox back.
$('#quarantine-checkbox')
.prop("checked", false);
}
else {
// Flip the checkbox back.
$('#quarantine-checkbox')
.prop("checked", true);
}
});
return;
}
sup.HideModal('#waitwait-modal');
}
sup.ShowModal('#waitwait-modal');
var xmlthing = sup.CallServerMethod(ajaxurl, "status", "Quarantine",
{"uuid" : uuid,
"quarantine" : mode});
xmlthing.done(callback);
}
//
// Get Max Extension and update the table.
//
......
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