* Mark the "current" builds in a jobset, i.e. those corresponding to

the derivations that the jobset currently contains.  This is
  necessary to allow the "latest" channel to contain the correct
  builds when the sources of a jobset are reverted.
This commit is contained in:
Eelco Dolstra 2009-10-02 16:06:28 +00:00
parent 9d99bb3342
commit e9cf409d80
22 changed files with 98 additions and 59 deletions

View file

@ -26,7 +26,7 @@ sub overview : Chained('job') PathPart('') Args(0) {
getBuildStats($c, scalar $c->stash->{job}->builds);
$c->stash->{systems} = [$c->stash->{job}->builds->search({}, {select => ["system"], distinct => 1})];
$c->stash->{systems} = [$c->stash->{job}->builds->search({iscurrent => 1}, {select => ["system"], distinct => 1})];
}

View file

@ -8,8 +8,8 @@ use base 'DBIx::Class::Schema';
__PACKAGE__->load_classes;
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-07-07 14:36:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tt53dmgGYiV3yqHvnrSwkg
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-02 15:59:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:uBemU8brohK9UDFJ9KC1iA
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -103,8 +103,8 @@ __PACKAGE__->belongs_to(
);
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-07-07 14:36:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:02BDWXRn4LMcb0LFjHXqjg
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-02 15:59:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3l2Qu/wpPEb/xsXoyeRviQ
use Hydra::Helper::Nix;

View file

@ -91,8 +91,8 @@ __PACKAGE__->set_primary_key("build", "productnr");
__PACKAGE__->belongs_to("build", "Hydra::Schema::Builds", { id => "build" });
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-07-07 14:36:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Fqzw8pcHMrUjdJZ/a43D3w
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-02 15:59:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:/AUVD2QjjkeQmFkKEim0Gw
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -86,8 +86,8 @@ __PACKAGE__->set_primary_key("id");
__PACKAGE__->belongs_to("id", "Hydra::Schema::Builds", { id => "id" });
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-07-07 14:36:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:KjrreyjxFwFTGDzdA9J42w
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-02 15:59:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:L/qLimgzcHeLjsKom3t1XQ
__PACKAGE__->belongs_to(
"failedDep",

View file

@ -43,8 +43,8 @@ __PACKAGE__->set_primary_key("id");
__PACKAGE__->belongs_to("id", "Hydra::Schema::Builds", { id => "id" });
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-07-07 14:36:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:jgOkt31QNifyPD8Y0rkVBA
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-02 15:59:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:I2cNoG9FOWDlICSy4Ndftw
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -91,7 +91,7 @@ __PACKAGE__->set_primary_key("build", "stepnr");
__PACKAGE__->belongs_to("build", "Hydra::Schema::Builds", { id => "build" });
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-07-07 14:36:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7z14GDq6a8ndBoj3Mx/3TQ
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-02 15:59:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:oCn8y9Nsffa6WOnm44lyqQ
1;

View file

@ -116,6 +116,8 @@ __PACKAGE__->add_columns(
is_nullable => 1,
size => undef,
},
"iscurrent",
{ data_type => "integer", default_value => 0, is_nullable => 1, size => undef },
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" });
@ -161,8 +163,8 @@ __PACKAGE__->has_many(
);
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-07-07 14:36:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:mTc++yn7RST163jLNJkXaw
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-02 15:59:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:8r7Yv4O8WF2YU4sOjn0Q8w
use Hydra::Helper::Nix;
@ -217,7 +219,7 @@ sub makeQueries {
" where x.project = c.project and x.jobset = c.jobset and x.job = c.job and x.system = c.system and " .
" x.id > c.id and r.buildstatus != r2.buildstatus)";
# Urgh, can't use "*" in the "select" here because of the status change join.
makeSource('JobStatus' . $name, "select x.id, x.finished, x.timestamp, x.project, x.jobset, x.job, x.nixname, x.description, x.drvpath, x.outpath, x.system, x.longdescription, x.license, x.homepage, x.maintainers, b.id as statusChangeId, b.timestamp as statusChangeTime from (select project, jobset, job, system, max(id) as id from Builds where finished = 1 $constraint group by project, jobset, job, system) as latest natural join Builds x $joinWithStatusChange");
makeSource('JobStatus' . $name, "select x.id, x.finished, x.timestamp, x.project, x.jobset, x.job, x.nixname, x.description, x.drvpath, x.outpath, x.system, x.longdescription, x.license, x.homepage, x.maintainers, x.isCurrent, b.id as statusChangeId, b.timestamp as statusChangeTime from (select project, jobset, job, system, max(id) as id from Builds where finished = 1 $constraint group by project, jobset, job, system) as latest natural join Builds x $joinWithStatusChange");
makeSource('LatestSucceeded' . $name, "select * from (select project, jobset, job, system, max(id) as id from Builds natural join BuildResultInfo where finished = 1 and buildStatus = 0 $constraint group by project, jobset, job, system) as latest natural join Builds x");
}

View file

@ -47,8 +47,8 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("srcpath", "sha256hash");
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-07-07 14:36:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:sEZCtuR96OmFAZe4ykVTUA
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-02 15:59:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:eLemrXw7iydgI6zhFrghRg
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -40,8 +40,8 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("uri", "revision");
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-07-07 14:36:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ImarwuHMkKrQ2GemxREDig
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-02 15:59:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:f2Xn8X5aO9Gud7LHrc/b2g
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -75,8 +75,8 @@ __PACKAGE__->belongs_to(
);
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-07-07 14:36:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OFEAwA4W5q0AF8uZ3JswFQ
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-02 15:59:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:w5CXchrT0/ueNgxnKv6TPg
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -69,8 +69,8 @@ __PACKAGE__->belongs_to(
);
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-07-07 14:36:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:kcIcgSux+SzIH7FQs2cnAw
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-02 15:59:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CQg509K7bBReX30DeMC7ww
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -65,8 +65,8 @@ __PACKAGE__->has_many(
);
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-07-07 14:36:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:SkF1SaumgGAQvR9mUbPV+Q
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-02 15:59:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FzkQQT8t8OET0a0teF3lHA
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -101,8 +101,8 @@ __PACKAGE__->has_many(
);
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-07-07 14:36:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lMdNiE6x4qZLK14+jEM7YQ
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-02 15:59:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:eu0jlMKE2aMvQRv4LynlIA
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -76,8 +76,8 @@ __PACKAGE__->has_many(
);
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-07-07 14:36:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lDNoBncP2KhnrfbQIg+Usw
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-02 15:59:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:aBN2ry0QEPIhQu6tlgk7RQ
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -66,8 +66,8 @@ __PACKAGE__->belongs_to(
);
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-07-07 14:36:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xaWTZqtzPyMq/xqi0ZFCDg
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-02 15:59:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Mm9VR//LwfM88N54dtmuxg
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -45,8 +45,8 @@ __PACKAGE__->has_many(
);
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-07-07 14:36:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:sYojSdWhlGMAL7Vj/UynBw
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-02 15:59:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:c6FKyR68F1a8wLivK9ztog
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -21,8 +21,8 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("system");
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-07-07 14:36:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QYzvQmgXtV3NURhO5j5F4Q
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-02 15:59:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:SYnu+3J84FXFqkSu8jxkPg
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -28,8 +28,8 @@ __PACKAGE__->set_primary_key("username", "role");
__PACKAGE__->belongs_to("username", "Hydra::Schema::Users", { username => "username" });
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-07-07 14:36:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:syo00cqS/fp5mJt2jg+YJw
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-02 15:59:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pRBijh3yc0x4knK6tU4iTw
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -50,8 +50,8 @@ __PACKAGE__->has_many(
);
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-07-07 14:36:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZH7GmAkTPdZm7G5aCp746A
# Created by DBIx::Class::Schema::Loader v0.04999_06 @ 2009-10-02 15:59:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:d4m+IH9KxIcgId+XF23txg
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -252,7 +252,7 @@ sub fetchInputs {
sub checkJob {
my ($project, $jobset, $inputInfo, $nixExprInput, $job) = @_;
my ($project, $jobset, $inputInfo, $nixExprInput, $job, $currentBuilds) = @_;
my $jobName = $job->{jobName};
my $drvPath = $job->{drvPath};
@ -273,15 +273,36 @@ sub checkJob {
$jobInDB->update({firstevaltime => time})
unless defined $jobInDB->firstevaltime;
# Have we already done this build (in this job)?
if (scalar($jobInDB->builds->search({outPath => $outPath})) > 0) {
print "already scheduled/done\n";
return;
# Have we already done this build (in this job)? Don't do it
# again unless it has been garbage-collected. The latest
# builds for each platforms are GC roots, so they shouldn't be
# GCed. However, if a job has reverted to a previous state,
# it's possible that a GCed build becomes current again. In
# that case we have to rebuild it to ensure that it appears in
# channels etc.
my @previousBuilds = $jobInDB->builds->search({outPath => $outPath}, {order_by => "id"});
if (scalar(@previousBuilds) > 0) {
foreach my $build (@previousBuilds) {
if (!$build->finished) {
print "already scheduled as build ", $build->id, "\n";
$currentBuilds->{$build->id} = 1;
return;
}
}
if (isValidPath($outPath)) {
print "already done as build ", $previousBuilds[0]->id, "\n";
# Mark the previous build as "current" so that it will
# appear in the "latest" channel for this
# project/jobset/job.
$previousBuilds[0]->update({iscurrent => 1});
$currentBuilds->{$previousBuilds[0]->id} = 1;
return;
}
print "already done as build ", $previousBuilds[0]->id,
"; rebuilding because it was garbage-collected\n";
}
# Nope, so add it.
print "adding to queue\n";
my $build = $jobInDB->builds->create(
{ finished => 0
, timestamp => time()
@ -294,8 +315,13 @@ sub checkJob {
, drvpath => $drvPath
, outpath => $outPath
, system => $job->{system}
, iscurrent => 1
});
print "added to queue as build ", $build->id, "\n";
$currentBuilds->{$build->id} = 1;
$build->create_related('buildschedulinginfo',
{ priority => $priority
, busy => 0
@ -403,20 +429,22 @@ sub checkJobset {
or die "cannot parse XML output";
# Schedule each successfully evaluated job.
my %currentBuilds;
foreach my $job (permute @{$jobs->{job}}) {
next if $job->{jobName} eq "";
print "considering job " . $job->{jobName} . "\n";
checkJob($project, $jobset, $inputInfo, $nixExprInput, $job);
checkJob($project, $jobset, $inputInfo, $nixExprInput, $job, \%currentBuilds);
}
# Mark all existing jobs that we haven't seen as inactive.
my %jobNames;
$jobNames{$_->{jobName}}++ foreach @{$jobs->{job}};
my %failedJobNames;
push @{$failedJobNames{$_->{location}}}, $_->{msg} foreach @{$jobs->{error}};
txn_do($db, sub {
# Mark all existing jobs that we haven't seen as inactive.
my %jobNames;
$jobNames{$_->{jobName}}++ foreach @{$jobs->{job}};
my %failedJobNames;
push @{$failedJobNames{$_->{location}}}, $_->{msg} foreach @{$jobs->{error}};
$jobset->update({lastcheckedtime => time});
foreach my $jobInDB ($jobset->jobs->all) {
@ -428,8 +456,16 @@ sub checkJobset {
$jobInDB->update({errormsg => undef});
}
}
});
# Clear the "current" flag on all builds that are no longer
# current.
foreach my $build ($jobset->builds->search({iscurrent => 1})) {
print "current is ", $build->id, "\n";
$build->update({iscurrent => 0}) unless $currentBuilds{$build->id};
}
});
# Store the errors messages for jobs that failed to evaluate.
my $msg = "";
foreach my $error (@{$jobs->{error}}) {

View file

@ -26,6 +26,8 @@ create table Builds (
license text, -- meta.license
homepage text, -- meta.homepage
maintainers text, -- meta.maintainers (concatenated, comma-separated)
isCurrent integer default 0,
foreign key (project) references Projects(name), -- ignored by sqlite
foreign key (project, jobset) references Jobsets(project, name), -- ignored by sqlite
@ -409,6 +411,5 @@ create index IndexBuildInputsByDependency on BuildInputs(dependency);
create index IndexBuildsByTimestamp on Builds(timestamp);
create index IndexBuildsByJobAndSystem on Builds(project, jobset, job, system);
create index IndexBuildResultInfo on BuildResultInfo(id); -- primary key index, not created automatically by PostgreSQL
create index indexbuild on buildproducts(build)
create index indexbuildtype on buildproducts(build, type)
create index IndexBuild on BuildProducts(build);
create index IndexBuildType on BuildProducts(build, type);