Commit f6d48f9c authored by Leigh Stoller's avatar Leigh Stoller

Minor tweaks to imaging support:

1. Use distinct imaging-failed status to indicate a failure, instead of
   leaving instance in imaging.

2. Leave the refresh button enabled so that user can refresh the instance,
   and if the backend sliver is "ready" then switch the instance back to
   ready.

3. The snapshot loop now does the same as above; tell the user the imaging
   failed, but move the instance back to ready if the sliver is ready.
parent b7ca1586
......@@ -147,7 +147,8 @@ sub KillFailedInstances()
{
my $query_result =
DBQueryWarn("select uuid,status from apt_instances ".
"where (status='failed' or status='imaging') and ".
"where (status='failed' or ".
" status='imaging' or status='imaging-failed') and ".
" (UNIX_TIMESTAMP(now()) - ".
" UNIX_TIMESTAMP(created) > 7200)");
return
......@@ -161,7 +162,7 @@ sub KillFailedInstances()
}
print STDERR "$instance is in the $status state\n";
if ($status eq "imaging") {
if ($status eq "imaging" || $status eq "imaging-failed") {
#
# Move it back to the ready state. But must lock so as not to
# collide with with sa_daemon or the user.
......
......@@ -381,6 +381,7 @@ sub DoSnapshot()
my $seconds = 1200;
my $interval = 5;
my $ready = 0;
my $sliver_ready = 0;
my $failed = 0;
# do not want this in the args for calls below.
delete($args->{'sliver_urn'});
......@@ -424,6 +425,10 @@ sub DoSnapshot()
$failed = 1;
last;
}
elsif ($blob->{'status'} eq "ready") {
$sliver_ready = 1;
}
#
# We are watching for the image status to report ready or failed.
#
......@@ -498,6 +503,17 @@ sub DoSnapshot()
if (defined($logfile));
exit(0);
bad:
if ($sliver_ready) {
#
# If the sliver comes back ready in spite of the imaging failure,
# then change the instance back to ready. User will already know
# that the imaging failed.
#
$instance->SetStatus("ready");
}
else {
$instance->SetStatus("imaging-failed");
}
print STDERR "$errmsg\n";
if (defined($errmsg)) {
$webtask->Exited($errcode);
......
......@@ -364,6 +364,14 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
status_html = "<font color=red>imaging</font>";
DisableButtons();
}
else if (status == 'imaging-failed') {
bgtype = "panel-danger";
status_message = "Your disk image request failed!";
status_html = "<font color=red>imaging-failed</font>";
DisableButtons();
EnableButton("terminate");
EnableButton("refresh");
}
else if (status == 'terminating' || status == 'terminated') {
status_html = "<font color=red>" + status + "</font>";
bgtype = "panel-danger";
......
......@@ -553,10 +553,6 @@ function Do_Refresh()
SPITAJAX_ERROR(1, "Not enough permission. Maybe Clone instead?");
return;
}
if ($instance->status() != "ready" && $instance->status() != "failed") {
SPITAJAX_ERROR(1, "Experiment is currently busy");
return;
}
#
# Call out to the backend.
#
......
......@@ -296,7 +296,8 @@ class ImageDataset
function id() { return $this->dataset_id(); }
function creator_uid() { return $this->image->creator(); }
function owner_uid() { return $this->image->creator(); }
function uuid() { return $this->image->uuid(); }
# Use the image uuid here.
function uuid() { return $this->image->image_uuid(); }
function pid() { return $this->image->pid(); }
function pid_idx() { return $this->image->pid_idx(); }
function gid() { return $this->image->pid(); }
......
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