From 4404800ad891def577ea64368bacc21c90f17885 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 14 Mar 2009 22:34:22 +0000 Subject: [PATCH] * Release sets: need to include the jobset name to disambiguate between jobs with the same name from different jobsets (e.g. trunk vs. branch). --- src/lib/Hydra/Controller/Root.pm | 14 ++++++++++++-- src/lib/Hydra/Helper/Nix.pm | 4 ++-- src/root/edit-releaseset.tt | 2 +- src/sql/hydra.sql | 4 +++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index befabefb..b2be88eb 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -117,10 +117,20 @@ sub updateReleaseSet { my $description = trim $c->request->params->{"job-$baseName-description"}; my $attrs = trim $c->request->params->{"job-$baseName-attrs"}; - die "Invalid job name: $name" unless $name =~ /^\w+$/; + $name =~ /^(\w+):(\w+)$/ or error($c, "Invalid job name: $name"); + my $jobsetName = $1; + my $jobName = $2; + + error($c, "Jobset `$jobsetName' doesn't exist.") + unless $releaseSet->project->jobsets->find({name => $jobsetName}); + + # !!! We could check whether the job exists, but that would + # require the scheduler to have seen the job, which may not be + # the case. $releaseSet->releasesetjobs->create( - { job => $name + { jobset => $jobsetName + , job => $jobName , description => $description , attrs => $attrs , isprimary => $c->request->params->{"primary"} eq $baseName ? 1 : 0 diff --git a/src/lib/Hydra/Helper/Nix.pm b/src/lib/Hydra/Helper/Nix.pm index f7428a4b..1383202d 100644 --- a/src/lib/Hydra/Helper/Nix.pm +++ b/src/lib/Hydra/Helper/Nix.pm @@ -124,7 +124,7 @@ sub attrsToSQL { sub getPrimaryBuildsForReleaseSet { my ($project, $primaryJob) = @_; my @primaryBuilds = $project->builds->search( - { job => $primaryJob->get_column('job'), finished => 1 }, + { jobset => $primaryJob->get_column('jobset'), job => $primaryJob->get_column('job'), finished => 1 }, { join => 'resultInfo', order_by => "timestamp DESC" , '+select' => ["resultInfo.releasename"], '+as' => ["releasename"] , where => \ attrsToSQL($primaryJob->attrs, "me.id") @@ -154,7 +154,7 @@ sub getRelease { # as input. If there are multiple, prefer successful # ones, and then oldest. !!! order_by buildstatus is hacky ($thisBuild) = $primaryBuild->dependentBuilds->search( - { job => $job->get_column('job'), finished => 1 }, + { jobset => $job->get_column('jobset'), job => $job->get_column('job'), finished => 1 }, { join => 'resultInfo', rows => 1 , order_by => ["buildstatus", "timestamp"] , where => \ attrsToSQL($job->attrs, "build.id") diff --git a/src/root/edit-releaseset.tt b/src/root/edit-releaseset.tt index c2f68001..d8b82a2a 100644 --- a/src/root/edit-releaseset.tt +++ b/src/root/edit-releaseset.tt @@ -14,7 +14,7 @@ "$n") %] /> - "$baseName-name", name => "$baseName-name", value => job.job) %] /> + "$baseName-name", name => "$baseName-name", value => "$job.jobset:$job.job") %] /> "$baseName-description", name => "$baseName-description", value => job.description) %] /> "$baseName-attrs", name => "$baseName-attrs", value => job.attrs) %] /> diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql index 93206968..32ebcc04 100644 --- a/src/sql/hydra.sql +++ b/src/sql/hydra.sql @@ -43,7 +43,7 @@ create table BuildSchedulingInfo ( logfile text, -- if busy, the path of the logfile - disabled integer not null default 0, -- true means hold this job until its re-enabled + disabled integer not null default 0, startTime integer, -- if busy, time we started @@ -269,6 +269,8 @@ create table Jobs ( firstEvalTime integer, -- first time the scheduler saw this job lastEvalTime integer, -- last time the scheduler saw this job + disabled integer not null default 0, + primary key (project, jobset, name), foreign key (project) references Projects(name) on delete cascade, -- ignored by sqlite foreign key (project, jobset) references Jobsets(project, name) on delete cascade -- ignored by sqlite