From 8f42bf303f7e77cccb5914251b08188f6092fb72 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 10 Nov 2008 10:18:50 +0000 Subject: [PATCH] --- .../lib/HydraFrontend/Controller/Root.pm | 1 + src/HydraFrontend/lib/HydraFrontend/Schema.pm | 4 +-- .../lib/HydraFrontend/Schema/Buildlogs.pm | 4 +-- .../lib/HydraFrontend/Schema/Buildproducts.pm | 4 +-- .../lib/HydraFrontend/Schema/Builds.pm | 14 ++++++-- .../lib/HydraFrontend/Schema/Inputs.pm | 4 +-- .../lib/HydraFrontend/Schema/Jobs.pm | 18 ++++++++-- .../HydraFrontend/Schema/Jobsetinputalts.pm | 6 ++-- .../lib/HydraFrontend/Schema/Jobsetinputs.pm | 6 ++-- .../lib/HydraFrontend/Schema/Jobsets.pm | 22 +++++++++++-- .../lib/HydraFrontend/Schema/Projects.pm | 14 ++++++-- src/HydraFrontend/root/build.tt | 10 +++--- src/HydraFrontend/root/index.tt | 21 ++++++++++++ src/HydraFrontend/root/short-build-info.tt | 4 +-- src/hydra.sql | 33 ++++++++++++------- src/scheduler.pl | 11 ++++--- 16 files changed, 129 insertions(+), 47 deletions(-) diff --git a/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm b/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm index 53d2d10f..9bf9caba 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm @@ -29,6 +29,7 @@ sub getBuild { sub index :Path :Args(0) { my ( $self, $c ) = @_; $c->stash->{template} = 'index.tt'; + $c->stash->{jobs} = [$c->model('DB::Jobs')->all]; $c->stash->{projects} = [$c->model('DB::Projects')->all]; $c->stash->{allBuilds} = [$c->model('DB::Builds')->search(undef, {order_by => "timestamp DESC"})]; # Get the latest build for each unique job. diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema.pm b/src/HydraFrontend/lib/HydraFrontend/Schema.pm index 64759718..41bd4553 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema.pm @@ -8,8 +8,8 @@ use base 'DBIx::Class::Schema'; __PACKAGE__->load_classes; -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-09 01:36:21 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:G17vptu+2rEUXbsqVtoXzQ +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-10 10:30:11 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xP97YDrN7Bm2B/BlbQJ7fQ # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildlogs.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildlogs.pm index e3ce113f..5c9991a0 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildlogs.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildlogs.pm @@ -21,8 +21,8 @@ __PACKAGE__->set_primary_key("build", "logphase"); __PACKAGE__->belongs_to("build", "HydraFrontend::Schema::Builds", { id => "build" }); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-09 01:36:21 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xvWlrugDQD11vH+7f91K0A +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-10 10:30:11 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pt0CJFX1pP9Z2TjqrTjTkw # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildproducts.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildproducts.pm index 2348498b..9aa4387e 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildproducts.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildproducts.pm @@ -21,8 +21,8 @@ __PACKAGE__->set_primary_key("build", "path"); __PACKAGE__->belongs_to("build", "HydraFrontend::Schema::Builds", { id => "build" }); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-09 01:36:21 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:SMsT6htcybeWNHhv82+ilA +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-10 10:30:11 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3NKUaF4u4H6ZmIRCeva8yA # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Builds.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Builds.pm index c370d01c..3f2152f7 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema/Builds.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Builds.pm @@ -38,6 +38,16 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 0, size => undef }, ); __PACKAGE__->set_primary_key("id"); +__PACKAGE__->belongs_to( + "project", + "HydraFrontend::Schema::Projects", + { name => "project" }, +); +__PACKAGE__->belongs_to( + "jobset", + "HydraFrontend::Schema::Jobsets", + { name => "jobset", project => "project" }, +); __PACKAGE__->has_many( "inputs", "HydraFrontend::Schema::Inputs", @@ -55,8 +65,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-09 01:36:21 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:nfVureYYGM1V/NHroQA5Tw +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-10 10:30:11 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:8s5Z03ugocOVb021EwGVag __PACKAGE__->has_many(dependents => 'HydraFrontend::Schema::Inputs', 'dependency'); diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Inputs.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Inputs.pm index 3ae7e42b..c184ac4c 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema/Inputs.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Inputs.pm @@ -35,8 +35,8 @@ __PACKAGE__->set_primary_key("id"); __PACKAGE__->belongs_to("build", "HydraFrontend::Schema::Builds", { id => "build" }); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-09 01:36:21 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3PAsUD+79bZk4vGeSyyACg +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-10 10:30:11 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:AzV6B/6CCrroPlO32n2p3A __PACKAGE__->belongs_to("dependency", "HydraFrontend::Schema::Builds", { id => "dependency" }); diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Jobs.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Jobs.pm index 81274320..1dff2914 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema/Jobs.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Jobs.pm @@ -14,6 +14,10 @@ __PACKAGE__->add_columns( { data_type => "integer", is_nullable => 0, size => undef }, "priority", { data_type => "integer", is_nullable => 0, size => undef }, + "busy", + { data_type => "integer", is_nullable => 0, size => undef }, + "locker", + { data_type => "text", is_nullable => 0, size => undef }, "project", { data_type => "text", is_nullable => 0, size => undef }, "jobset", @@ -30,10 +34,20 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 0, size => undef }, ); __PACKAGE__->set_primary_key("id"); +__PACKAGE__->belongs_to( + "project", + "HydraFrontend::Schema::Projects", + { name => "project" }, +); +__PACKAGE__->belongs_to( + "jobset", + "HydraFrontend::Schema::Jobsets", + { name => "jobset", project => "project" }, +); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-09 01:36:21 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:T8O0XTTOZXapWpJbzjKLTw +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-10 10:30:11 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:GubRofAmJ/sbJbjyV3aKSQ # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputalts.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputalts.pm index b29816d2..5c2ebb9a 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputalts.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputalts.pm @@ -6,7 +6,7 @@ use warnings; use base 'DBIx::Class'; __PACKAGE__->load_components("Core"); -__PACKAGE__->table("jobSetInputAlts"); +__PACKAGE__->table("jobsetInputAlts"); __PACKAGE__->add_columns( "project", { data_type => "text", is_nullable => 0, size => undef }, @@ -33,8 +33,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-09 01:36:21 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:DzEHCDlnponciGmGASknlg +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-10 10:30:11 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZjjWLbAWExxOqsDz41A3KA # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputs.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputs.pm index 6093bde3..1a371df0 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputs.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputs.pm @@ -6,7 +6,7 @@ use warnings; use base 'DBIx::Class'; __PACKAGE__->load_components("Core"); -__PACKAGE__->table("jobSetInputs"); +__PACKAGE__->table("jobsetInputs"); __PACKAGE__->add_columns( "project", { data_type => "text", is_nullable => 0, size => undef }, @@ -43,8 +43,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-09 01:36:21 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Lm2oIWEUSHFICYMX2qmTfw +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-10 10:30:11 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:6hzbFjPWQ872UxFhhpxjFg # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsets.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsets.pm index 019a1052..236e06b3 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsets.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsets.pm @@ -6,7 +6,7 @@ use warnings; use base 'DBIx::Class'; __PACKAGE__->load_components("Core"); -__PACKAGE__->table("jobSets"); +__PACKAGE__->table("jobsets"); __PACKAGE__->add_columns( "name", { data_type => "text", is_nullable => 0, size => undef }, @@ -20,6 +20,14 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 0, size => undef }, ); __PACKAGE__->set_primary_key("project", "name"); +__PACKAGE__->has_many( + "builds", + "HydraFrontend::Schema::Builds", + { + "foreign.jobset" => "self.name", + "foreign.project" => "self.project", + }, +); __PACKAGE__->belongs_to( "project", "HydraFrontend::Schema::Projects", @@ -38,10 +46,18 @@ __PACKAGE__->has_many( "foreign.project" => "self.project", }, ); +__PACKAGE__->has_many( + "jobs", + "HydraFrontend::Schema::Jobs", + { + "foreign.jobset" => "self.name", + "foreign.project" => "self.project", + }, +); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-09 01:36:21 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:EmATMMeNmMd2AI8lVzcLFA +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-10 10:30:11 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:oRV4yw0DWG5PI0agcM7QHA # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Projects.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Projects.pm index e43a0b0a..b0b7069d 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema/Projects.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Projects.pm @@ -12,15 +12,25 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 0, size => undef }, ); __PACKAGE__->set_primary_key("name"); +__PACKAGE__->has_many( + "builds", + "HydraFrontend::Schema::Builds", + { "foreign.project" => "self.name" }, +); __PACKAGE__->has_many( "jobsets", "HydraFrontend::Schema::Jobsets", { "foreign.project" => "self.name" }, ); +__PACKAGE__->has_many( + "jobs", + "HydraFrontend::Schema::Jobs", + { "foreign.project" => "self.name" }, +); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-09 01:36:21 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZifQocKoHOPRrJQSPggZ+w +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-10 10:30:11 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9SeEXSEOH1ocrdkoa7fx5Q # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/HydraFrontend/root/build.tt b/src/HydraFrontend/root/build.tt index 211b7a32..2b7137c3 100644 --- a/src/HydraFrontend/root/build.tt +++ b/src/HydraFrontend/root/build.tt @@ -1,7 +1,7 @@ [% WRAPPER layout.tt title="Hydra Overview" %] [% USE date %] -

Job [% build.project %]:[% build.attrname %] build [% id %]

+

Job [% build.project.name %]:[% build.attrname %] build [% id %]

Information

@@ -13,11 +13,11 @@ Project: - [% build.project %] + [% build.project.name %] Jobset: - [% build.jobset %] + [% build.jobset.name %] Job name: @@ -87,7 +87,7 @@ [% input.type %] [% IF input.type == "build" %] - Job [% input.dependency.project %]:[% input.dependency.attrname %] build [% input.dependency.id %] + Job [% input.dependency.project.name %]:[% input.dependency.attrname %] build [% input.dependency.id %] [% ELSIF input.type == "string" %] "[% input.value %]" [% ELSE %] @@ -153,7 +153,7 @@ [% FOREACH input IN build.dependents -%] - Job [% input.build.project %]:[% input.build.attrname %] build [% input.build.id %] + Job [% input.build.project.name %]:[% input.build.attrname %] build [% input.build.id %] [% input.name %] [% input.build.system %] [% date.format(input.build.timestamp, '%Y-%m-%d %H:%M:%S') %] diff --git a/src/HydraFrontend/root/index.tt b/src/HydraFrontend/root/index.tt index 483663c1..d10ffe10 100644 --- a/src/HydraFrontend/root/index.tt +++ b/src/HydraFrontend/root/index.tt @@ -1,4 +1,25 @@ [% WRAPPER layout.tt title="Hydra Overview" %] +[% USE date %] + +

Queue

+ + + + + + + [% FOREACH job IN jobs -%] + + + + + + + + + [% END -%] + +
PriorityProjectJobSystemTimestampDescription
[% job.priority %][% job.project.name %][% job.jobset.name %][% job.system %][% date.format(job.timestamp, '%Y-%m-%d %H:%M:%S') %][% job.description %]

Job status

diff --git a/src/HydraFrontend/root/short-build-info.tt b/src/HydraFrontend/root/short-build-info.tt index 12990614..a3549b70 100644 --- a/src/HydraFrontend/root/short-build-info.tt +++ b/src/HydraFrontend/root/short-build-info.tt @@ -9,8 +9,8 @@ [% END %] [% build.id %] - [% build.project %] - [% build.attrname %] + [% build.project.name %] + [% build.attrname %] [% build.system %] [% date.format(build.timestamp, '%Y-%m-%d %H:%M:%S') %] [% build.description %] diff --git a/src/hydra.sql b/src/hydra.sql index ae3dfddb..5cbce7cf 100644 --- a/src/hydra.sql +++ b/src/hydra.sql @@ -4,7 +4,7 @@ create table builds ( -- Info about the inputs. project text not null, -- !!! foreign key - jobSet text not null, -- !!! foreign key + jobset text not null, -- !!! foreign key attrName text not null, -- Info about the build result. @@ -16,7 +16,10 @@ create table builds ( errorMsg text, -- error message in case of a Nix failure startTime integer, -- in Unix time, 0 = used cached build result stopTime integer, - system text not null + system text not null, + + foreign key (project) references projects(name), -- ignored by sqlite + foreign key (project, jobset) references jobsets(project, name) -- ignored by sqlite ); @@ -28,7 +31,7 @@ create table inputs ( build integer, job integer, - -- Copied from the jobSetInputs from which the build was created. + -- Copied from the jobsetinputs from which the build was created. name text not null, type text not null, uri text, @@ -83,29 +86,29 @@ create table projects ( -- A jobset consists of a set of inputs (e.g. SVN repositories), one -- of which contains a Nix expression containing an attribute set -- describing build jobs. -create table jobSets ( +create table jobsets ( name text not null, project text not null, description text, - nixExprInput text not null, -- name of the jobSetInput containing the Nix expression + nixExprInput text not null, -- name of the jobsetInput containing the Nix expression nixExprPath text not null, -- relative path of the Nix expression primary key (project, name), foreign key (project) references projects(name) on delete cascade, -- ignored by sqlite - foreign key (project, name, nixExprInput) references jobSetInputs(project, job, name) + foreign key (project, name, nixExprInput) references jobsetInputs(project, job, name) ); -create table jobSetInputs ( +create table jobsetInputs ( project text not null, jobset text not null, name text not null, type text not null, -- "svn", "cvs", "path", "file", "string" primary key (project, jobset, name), - foreign key (project, jobset) references jobSets(project, name) on delete cascade -- ignored by sqlite + foreign key (project, jobset) references jobsets(project, name) on delete cascade -- ignored by sqlite ); -create table jobSetInputAlts ( +create table jobsetInputAlts ( project text not null, jobset text not null, input text not null, @@ -118,7 +121,7 @@ create table jobSetInputAlts ( value text, -- for type == 'string' primary key (project, jobset, input, altnr), - foreign key (project, jobset, input) references jobSetInputs(project, jobset, name) on delete cascade -- ignored by sqlite + foreign key (project, jobset, input) references jobsetInputs(project, jobset, name) on delete cascade -- ignored by sqlite ); @@ -127,15 +130,21 @@ create table jobs ( timestamp integer not null, -- time this build was added to the db (in Unix time) priority integer not null, + + busy integer not null, -- true means someone is building this job now + locker text not null, -- !!! hostname/pid of the process building this job? -- Info about the inputs. project text not null, -- !!! foreign key - jobSet text not null, -- !!! foreign key + jobset text not null, -- !!! foreign key attrName text not null, -- What this job will build. description text, drvPath text not null, outPath text not null, - system text not null + system text not null, + + foreign key (project) references projects(name), -- ignored by sqlite + foreign key (project, jobset) references jobsets(project, name) -- ignored by sqlite ); diff --git a/src/scheduler.pl b/src/scheduler.pl index 66c75082..74fe6979 100644 --- a/src/scheduler.pl +++ b/src/scheduler.pl @@ -16,7 +16,7 @@ sub isValidPath { sub buildJob { - my ($project, $jobset, $jobName, $drvPath, $outPath, $usedInputs, $system) = @_; + my ($project, $jobset, $jobName, $description, $drvPath, $outPath, $usedInputs, $system) = @_; if (scalar($db->resultset('Builds')->search({project => $project->name, jobset => $jobset->name, attrname => $jobName, outPath => $outPath})) > 0) { print " already done\n"; @@ -58,6 +58,7 @@ sub buildJob { , project => $project->name , jobset => $jobset->name , attrname => $jobName + , description => $description , drvpath => $drvPath , outpath => $outPath , iscachedbuild => $isCachedBuild @@ -175,17 +176,17 @@ sub checkJob { my $infoXml = `nix-env -f $nixExprPath --query --available "*" --attr-path --out-path --drv-path --meta --xml --system-filter "*" --attr $jobName $extraArgs` or die "cannot get information about the job: $?"; - my $info = XMLin($infoXml, KeyAttr => ['attrPath', 'name']) + my $info = XMLin($infoXml, ForceArray => 1, KeyAttr => ['attrPath', 'name']) or die "cannot parse XML output"; - my $job = $info->{item}; - die if !defined $job || $job->{attrPath} ne $jobName; + my $job = $info->{item}->{$jobName}; + die if !defined $job; my $description = defined $job->{meta}->{description} ? $job->{meta}->{description}->{value} : ""; die unless $job->{drvPath} eq $drvPath; my $outPath = $job->{outPath}; - buildJob($project, $jobset, $jobName, $drvPath, $outPath, $inputInfo, $job->{system}); + buildJob($project, $jobset, $jobName, $description, $drvPath, $outPath, $inputInfo, $job->{system}); };