* Added a status page that shows all the currently executing build steps.

* Store the system type in the BuildSteps table.
* Don't query the queue size when serving static pages.  This prevents
  two unnecessary database queries per request.
This commit is contained in:
Eelco Dolstra 2010-08-31 15:27:46 +00:00
parent eb0c477549
commit f6715fa0ef
7 changed files with 73 additions and 9 deletions

View file

@ -35,7 +35,6 @@ sub view_build : Chained('build') PathPart('') Args(0) {
my $build = $c->stash->{build};
$c->stash->{template} = 'build.tt';
$c->stash->{curTime} = time;
$c->stash->{available} = isValidPath $build->outpath;
$c->stash->{drvAvailable} = isValidPath $build->drvpath;
$c->stash->{flashMsg} = $c->flash->{buildMsg};

View file

@ -12,14 +12,16 @@ __PACKAGE__->config->{namespace} = '';
sub begin :Private {
my ($self, $c) = @_;
my ($self, $c, @args) = @_;
$c->stash->{curUri} = $c->request->uri;
$c->stash->{version} = $ENV{"HYDRA_RELEASE"} || "<devel>";
$c->stash->{nixVersion} = $ENV{"NIX_RELEASE"} || "<devel>";
$c->stash->{nrRunningBuilds} = $c->model('DB::BuildSchedulingInfo')->search({ busy => 1 }, {})->count();
$c->stash->{nrQueuedBuilds} = $c->model('DB::BuildSchedulingInfo')->count();
$c->stash->{nixVersion} = $ENV{"NIX_RELEASE"} || "<devel>";
$c->stash->{curTime} = time;
if (scalar(@args) && $args[0] ne "static") {
$c->stash->{nrRunningBuilds} = $c->model('DB::BuildSchedulingInfo')->search({ busy => 1 }, {})->count();
$c->stash->{nrQueuedBuilds} = $c->model('DB::BuildSchedulingInfo')->count();
}
}
@ -74,6 +76,7 @@ sub queue :Local {
$c->stash->{flashMsg} = $c->flash->{buildMsg};
}
sub timeline :Local {
my ($self, $c) = @_;
my $pit = time();
@ -90,6 +93,17 @@ sub timeline :Local {
})];
}
sub status :Local {
my ($self, $c) = @_;
$c->stash->{steps} = [ $c->model('DB::BuildSteps')->search(
{ 'me.busy' => 1, 'schedulingInfo.busy' => 1 },
{ join => [ 'schedulingInfo' ]
, order_by => [ 'machine', 'outpath' ]
} ) ];
}
# Hydra::Base::Controller::ListBuilds needs this.
sub get_builds : Chained('/') PathPart('') CaptureArgs(0) {
my ($self, $c) = @_;

View file

@ -104,6 +104,13 @@ __PACKAGE__->table("BuildSteps");
is_nullable: 0
size: undef
=head2 system
data_type: text
default_value: undef
is_nullable: 1
size: undef
=cut
__PACKAGE__->add_columns(
@ -187,6 +194,13 @@ __PACKAGE__->add_columns(
},
"machine",
{ data_type => "text", default_value => "''", is_nullable => 0, size => undef },
"system",
{
data_type => "text",
default_value => undef,
is_nullable => 1,
size => undef,
},
);
__PACKAGE__->set_primary_key("build", "stepnr");
@ -203,7 +217,13 @@ Related object: L<Hydra::Schema::Builds>
__PACKAGE__->belongs_to("build", "Hydra::Schema::Builds", { id => "build" }, {});
# Created by DBIx::Class::Schema::Loader v0.05000 @ 2010-08-31 15:40:29
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CC/XBHMiRLuQSI+nEFW50g
# Created by DBIx::Class::Schema::Loader v0.05000 @ 2010-08-31 17:19:01
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:BU1na1One0SzUwilm7YmQQ
__PACKAGE__->belongs_to(
"schedulingInfo",
"Hydra::Schema::BuildSchedulingInfo",
{ id => "build" },
);
1;

View file

@ -53,10 +53,15 @@ tr.clickable:hover {
background-color: #E6EEFF;
cursor: pointer;
}
td.centered {
text-align: center;
}
td.right {
text-align: right;
}
.layoutTable td, .layoutTable th {
border-style: none;

24
src/root/status.tt Normal file
View file

@ -0,0 +1,24 @@
[% WRAPPER layout.tt title="Hydra status" %]
[% PROCESS common.tt %]
<h1>Hydra Status</h1>
<table class="tablesorter">
<thead>
<tr><th>Machine</th><th>Type</th><th>Build</th><th>Step</th><th>What</th><th>Since</th></tr>
</thead>
<tbody>
[% FOREACH step IN steps %]
<tr>
<td><tt>[% IF step.machine; step.machine.match('@(.*)').0; ELSE; 'localhost'; END %]</tt></td>
<td><tt>[% step.system %]</tt></td>
<td><a href="[% c.uri_for('/build' step.build.id) %]">[% step.build.id %]</a></td>
<td><a href="[% c.uri_for('/build' step.build.id 'nixlog' step.stepnr) %]">[% step.stepnr %]</a></td>
<td><tt>[% step.outpath.match('-(.*)').0 %]</tt></td>
<td class='right'>[% INCLUDE renderDuration duration = curTime - step.starttime %] </td>
</tr>
[% END %]
</tbody>
</table>
[% END %]

View file

@ -264,6 +264,7 @@ sub doBuild {
, type => 0 # = build
, drvpath => $drvPathStep
, outpath => $2
, system => $3
, logfile => $4
, busy => 1
, starttime => time

View file

@ -236,6 +236,7 @@ create table BuildSteps (
stopTime integer,
machine text not null default '',
system text,
primary key (build, stepnr),
foreign key (build) references Builds(id) on delete cascade