From f6715fa0ef3d7a58c614732d7ac6e4166c4d11af Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 31 Aug 2010 15:27:46 +0000 Subject: [PATCH] * 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. --- src/lib/Hydra/Controller/Build.pm | 1 - src/lib/Hydra/Controller/Root.pm | 26 ++++++++++++++++++++------ src/lib/Hydra/Schema/BuildSteps.pm | 24 ++++++++++++++++++++++-- src/root/static/css/hydra.css | 5 +++++ src/root/status.tt | 24 ++++++++++++++++++++++++ src/script/hydra_build.pl | 1 + src/sql/hydra.sql | 1 + 7 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 src/root/status.tt diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index 44b7a6fd..24992b9f 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -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}; diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index 41927ce7..b4e2ca68 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -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"} || ""; - $c->stash->{nixVersion} = $ENV{"NIX_RELEASE"} || ""; - - $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"} || ""; + $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) = @_; diff --git a/src/lib/Hydra/Schema/BuildSteps.pm b/src/lib/Hydra/Schema/BuildSteps.pm index 92320f68..9f695aa4 100644 --- a/src/lib/Hydra/Schema/BuildSteps.pm +++ b/src/lib/Hydra/Schema/BuildSteps.pm @@ -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 __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; diff --git a/src/root/static/css/hydra.css b/src/root/static/css/hydra.css index 452ae6b9..d3f3ed92 100644 --- a/src/root/static/css/hydra.css +++ b/src/root/static/css/hydra.css @@ -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; diff --git a/src/root/status.tt b/src/root/status.tt new file mode 100644 index 00000000..daf0a13e --- /dev/null +++ b/src/root/status.tt @@ -0,0 +1,24 @@ +[% WRAPPER layout.tt title="Hydra status" %] +[% PROCESS common.tt %] + +

Hydra Status

+ + + + + + + [% FOREACH step IN steps %] + + + + + + + + + [% END %] + +
MachineTypeBuildStepWhatSince
[% IF step.machine; step.machine.match('@(.*)').0; ELSE; 'localhost'; END %][% step.system %][% step.build.id %][% step.stepnr %][% step.outpath.match('-(.*)').0 %][% INCLUDE renderDuration duration = curTime - step.starttime %]
+ +[% END %] diff --git a/src/script/hydra_build.pl b/src/script/hydra_build.pl index c2ef427a..910b3750 100755 --- a/src/script/hydra_build.pl +++ b/src/script/hydra_build.pl @@ -264,6 +264,7 @@ sub doBuild { , type => 0 # = build , drvpath => $drvPathStep , outpath => $2 + , system => $3 , logfile => $4 , busy => 1 , starttime => time diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql index a6e4a8ba..ec83190f 100644 --- a/src/sql/hydra.sql +++ b/src/sql/hydra.sql @@ -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