Commit 2b9590e5 authored by Leigh Stoller's avatar Leigh Stoller

Start tracking errors in new apt_instance_failures table, storing the

exitcode and the exit message (the one we show to the user). Show the
counts on the dashboard page.

For now, I am not breaking out the errors on the dashboard page. Need
to think about how we break them out, also do we want to show any details
about failures.
parent cb237111
......@@ -482,7 +482,6 @@ sub Profile($)
# Record a history entry.
# We do this when the instance is terminated.
#
sub RecordHistory($$)
{
my ($self, $flags) = @_;
......@@ -506,6 +505,22 @@ sub RecordHistory($$)
return 0;
}
sub RecordError($$$)
{
my ($self, $exitcode, $message) = @_;
my $uuid = $self->uuid();
my $safe_message = DBQuoteSpecial($message);
DBQueryWarn("replace into apt_instance_failures ".
"select uuid,name,profile_id,profile_version,slice_uuid, ".
" creator,creator_idx,creator_uuid,pid,pid_idx, ".
" created,'$exitcode',$safe_message ".
" from apt_instances where uuid='$uuid'")
or return -1;
return 0;
}
#
# Locate Geni objects for creator and slice.
#
......
......@@ -782,6 +782,9 @@ if ($usestitcher) {
if ($rval) {
$slice->UnLock();
$instance->SetStatus("failed");
$instance->RecordError($rval,
(defined($webtask->output()) ?
$webtask->output() : ""));
$webtask->Exited(1);
exit($rval);
}
......@@ -794,6 +797,9 @@ else {
# error in the web ui).
#
if ($rval) {
$instance->RecordError($rval,
(defined($webtask->output()) ?
$webtask->output() : ""));
if ($rval == GENIRESPONSE_BADARGS ||
$rval == GENIRESPONSE_INSUFFICIENT_NODES ||
$rval == GENIRESPONSE_INSUFFICIENT_MEMORY ||
......@@ -982,6 +988,9 @@ $slice->UnLock();
if ($failed) {
$instance->SetStatus("failed");
# Webtask exit status set above.
$instance->RecordError($webtask->exitcode(),
(defined($webtask->output()) ?
$webtask->output() : ""));
}
else {
$instance->SetStatus("ready");
......
......@@ -143,6 +143,28 @@ CREATE TABLE `apt_instance_aggregates` (
PRIMARY KEY (`uuid`,`aggregate_urn`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `apt_instance_failures`
--
DROP TABLE IF EXISTS `apt_instance_failures`;
CREATE TABLE `apt_instance_failures` (
`uuid` varchar(40) NOT NULL default '',
`name` varchar(16) default NULL,
`profile_id` int(10) unsigned NOT NULL default '0',
`profile_version` int(10) unsigned NOT NULL default '0',
`slice_uuid` varchar(40) default NULL,
`creator` varchar(8) NOT NULL default '',
`creator_idx` mediumint(8) unsigned NOT NULL default '0',
`creator_uuid` varchar(40) NOT NULL default '',
`pid` varchar(48) default NULL,
`pid_idx` mediumint(8) unsigned default NULL,
`created` datetime default NULL,
`exitcode` int(10) default '0',
`exitmessage` mediumtext,
PRIMARY KEY (`uuid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `apt_instance_history`
--
......
......@@ -15,6 +15,22 @@
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `image_permissions`
--
DROP TABLE IF EXISTS `image_permissions`;
CREATE TABLE `image_permissions` (
`urn` varchar(128) default NULL,
`imagename` varchar(30) NOT NULL default '',
`image_uuid` varchar(40) NOT NULL default '',
`permission_type` enum('user','project') NOT NULL default 'user',
`permission_urn` varchar(128) NOT NULL default '',
PRIMARY KEY (`urn`,`permission_urn`),
UNIQUE KEY `uuidurn` (`image_uuid`,`permission_urn`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `image_versions`
--
......
use strict;
use libdb;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
if (!DBTableExists("apt_instance_failures")) {
DBQueryFatal("CREATE TABLE `apt_instance_failures` ( ".
" `uuid` varchar(40) NOT NULL default '', ".
" `name` varchar(16) default NULL, ".
" `profile_id` int(10) unsigned NOT NULL default '0', ".
" `profile_version` int(10) unsigned NOT NULL default '0', ".
" `slice_uuid` varchar(40) default NULL, ".
" `creator` varchar(8) NOT NULL default '', ".
" `creator_idx` mediumint(8) unsigned NOT NULL default '0', ".
" `creator_uuid` varchar(40) NOT NULL default '', ".
" `pid` varchar(48) default NULL, ".
" `pid_idx` mediumint(8) unsigned default NULL, ".
" `created` datetime default NULL, ".
" `exitcode` int(10) default '0', ".
" `exitmessage` mediumtext, ".
" PRIMARY KEY (`uuid`) ".
") ENGINE=MyISAM DEFAULT CHARSET=latin1");
}
return 0;
}
# Local Variables:
# mode:perl
# End:
......@@ -42,6 +42,7 @@ function Do_GetStats()
global $scales;
$started = array();
$errors = array();
foreach ($scales as $key => $age) {
$query_result =
......@@ -52,13 +53,15 @@ function Do_GetStats()
" where created > DATE_SUB(now(),interval $age second))");
$row = mysql_fetch_array($query_result);
$started[$key] = $row[0] + $row[1];
$query_result =
DBQueryFatal("select count(uuid) from apt_instance_failures ".
" where created > DATE_SUB(now(),interval $age second)");
$row = mysql_fetch_array($query_result);
$errors[$key] = $row[0] + $row[1];
}
$dashboard = array("started" => $started,
"errors" => array("Day" => "n/a",
"Week" => "n/a",
"Month" => "n/a",
"Year" => "n/a",
"Epoch" => "n/a"));
"errors" => $errors);
#
# What are most recent swapins
......
......@@ -28,7 +28,7 @@
<td><%- value %></td>
<% }); %>
</tr>
<tr class="hidden">
<tr>
<td>Errors</td>
<% _.each(dashboard.errors, function(value, key) { %>
<td><%- value %></td>
......
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