Commit 14d4bcbf authored by Leigh B Stoller's avatar Leigh B Stoller

Use a WebTask when creating a new instance, to allow passing along more

then just success/failure. For example, lets tell the user if the reason
for failure is lack of nodes.
parent 93ea7b7a
......@@ -578,6 +578,13 @@ if (!defined($instance)) {
$slice->Delete();
fatal("Could not create instance record for $quickvm_uuid");
}
#
# Create a webtask so that we can store additional information about
# the sliver while we wait. No worries if this fails.
#
$webtask = WebTask->Create($instance->uuid());
$webtask->AutoStore(1)
if (defined($webtask));
#
# Exit and let caller poll for status.
......@@ -593,6 +600,9 @@ if (!$debug) {
# All of the logging magic happens in here.
libaudit::AuditFork();
}
# Bind the process id.
$webtask->SetProcessID($PID)
if (defined($webtask));
#
# This creates the sliver and starts it.
......@@ -613,6 +623,15 @@ my $response =
if (!defined($response) || $response->code() != GENIRESPONSE_SUCCESS) {
$slice->Delete();
$instance->SetStatus("failed");
if (defined($webtask)) {
if (defined($response)) {
$webtask->output($response->output());
$webtask->Exited($response->code());
}
else {
$webtask->Exited(1);
}
}
fatal("CreateSliver failed: ".
(defined($response) ? $response->output() : "") . "\n");
}
......@@ -623,6 +642,7 @@ if (!defined($response) || $response->code() != GENIRESPONSE_SUCCESS) {
my $manifest = $response->value()->[1];
if (!defined($manifest)) {
$slice->UnLock();
$webtask->Exited(1) if (defined($webtask));
$instance->SetStatus("failed");
fatal("Could not find the manifest in the response!");
}
......@@ -656,6 +676,9 @@ while ($seconds > 0) {
print STDERR "SliverStatus failed";
if (defined($response)) {
print STDERR ": " . $response->output();
if (defined($webtask)) {
$webtask->output($response->output());
}
}
print STDERR "\n";
$failed = 1;
......@@ -691,9 +714,11 @@ if ($failed || !$ready) {
else {
print STDERR "$slice_urn failed.\n";
}
$webtask->Exited(1) if (defined($webtask));
}
else {
$instance->SetStatus("ready");
$webtask->Exited(0) if (defined($webtask));
}
$slice->UnLock();
exit(0);
......@@ -887,6 +912,7 @@ sub Terminate($)
done:
$instance->RecordHistory();
killit:
WebTask->DeleteByObject($instance);
$instance->Delete();
exit(0);
}
......
......@@ -267,7 +267,7 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
// It has not... perform the initilization
StatusWatchCallBack.laststatus = "";
}
var status = json.value;
var status = json.value.status;
if (json.code) {
alert("The server has returned an error: " + json.value);
status = "unknown";
......@@ -302,8 +302,14 @@ function (_, sup, moment, marked, UriTemplate, ShowImagingModal,
}
else if (status == 'failed') {
bgtype = "panel-danger";
status_message = "Something went wrong, sorry! " +
"We've been notified.";
if (_.has(json.value, "reason")) {
status_message = json.value.reason;
}
else {
status_message = "Something went wrong, sorry! " +
"We've been notified.";
}
status_html = "<font color=red>failed</font>";
if ($("#status_progress_div").length) {
$("#status_progress_div").removeClass("progress-striped");
......
......@@ -85,7 +85,18 @@ function Do_GetInstanceStatus()
if (StatusSetupAjax()) {
return;
}
SPITAJAX_RESPONSE($instance->status());
$blob = array();
$blob["status"] = $instance->status();
$webtask = WebTask::LookupByObject($instance->uuid());
if ($webtask) {
# We do not want to tell the user anything unless it would mean
# something to them. Not enough nodes is important.
if ($webtask->exitcode() == 26) {
$blob["reason"] = "Not enough free nodes, please try again later.";
}
}
SPITAJAX_RESPONSE($blob);
}
#
......@@ -237,7 +248,15 @@ function Do_RequestExtension()
SPITAJAX_ERROR(1, "You still have a week left!");
goto bad;
}
#
# The most we allow is a week out, no matter what they asked for.
# So if there are five days left and they asked for seven, we
# give them two.
#
$howlong = $howlong * 3600 * 24;
if ($expires_time + $howlong > time() + (3600 * 24 * 7)) {
$howlong = (3600 * 24 * 7) - diff;
}
}
}
$retval = SUEXEC("nobody", "nobody",
......
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