forked from lix-project/hydra
* In the scheduler, don't check if we've already done a build (except
against the set of current builds for the job). This ensures that the builds with the highest ID are what we want in the channel, even in case of reverts.
This commit is contained in:
parent
05c7989c3e
commit
076ef05578
2 changed files with 18 additions and 28 deletions
|
@ -90,6 +90,8 @@
|
||||||
alter table jobs add column disabled integer not null default 0;
|
alter table jobs add column disabled integer not null default 0;
|
||||||
alter table builds add column maintainers text;
|
alter table builds add column maintainers text;
|
||||||
|
|
||||||
|
alter table builds add column isCurrent integer default 0;
|
||||||
|
|
||||||
|
|
||||||
* Job selection:
|
* Job selection:
|
||||||
|
|
||||||
|
|
|
@ -273,34 +273,23 @@ sub checkJob {
|
||||||
$jobInDB->update({firstevaltime => time})
|
$jobInDB->update({firstevaltime => time})
|
||||||
unless defined $jobInDB->firstevaltime;
|
unless defined $jobInDB->firstevaltime;
|
||||||
|
|
||||||
# Have we already done this build (in this job)? Don't do it
|
# Don't add a build that has already been scheduled for this
|
||||||
# again unless it has been garbage-collected. The latest
|
# job, or has been built but is still a "current" build for
|
||||||
# builds for each platforms are GC roots, so they shouldn't be
|
# this job. Note that this means that if the sources of a job
|
||||||
# GCed. However, if a job has reverted to a previous state,
|
# are changed from A to B and then reverted to A, three builds
|
||||||
# it's possible that a GCed build becomes current again. In
|
# will be performed (though the last one will probably use the
|
||||||
# that case we have to rebuild it to ensure that it appears in
|
# cached result from the first). This ensures that the builds
|
||||||
# channels etc.
|
# with the highest ID will always be the ones that we want in
|
||||||
my @previousBuilds = $jobInDB->builds->search({outPath => $outPath}, {order_by => "id"});
|
# the channels.
|
||||||
|
# !!! Checking $drvPath doesn't take meta-attributes into
|
||||||
|
# account. For instance, do we want a new build to be
|
||||||
|
# scheduled if the meta.maintainers field is changed?
|
||||||
|
my @previousBuilds = $jobInDB->builds->search({drvPath => $drvPath, isCurrent => 1});
|
||||||
if (scalar(@previousBuilds) > 0) {
|
if (scalar(@previousBuilds) > 0) {
|
||||||
foreach my $build (@previousBuilds) {
|
print "already scheduled/built\n";
|
||||||
if (!$build->finished) {
|
$currentBuilds->{$_->id} = 1 foreach @previousBuilds;
|
||||||
print "already scheduled as build ", $build->id, "\n";
|
|
||||||
$currentBuilds->{$build->id} = 1;
|
|
||||||
return;
|
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.
|
# Nope, so add it.
|
||||||
my $build = $jobInDB->builds->create(
|
my $build = $jobInDB->builds->create(
|
||||||
|
@ -460,7 +449,6 @@ sub checkJobset {
|
||||||
# Clear the "current" flag on all builds that are no longer
|
# Clear the "current" flag on all builds that are no longer
|
||||||
# current.
|
# current.
|
||||||
foreach my $build ($jobset->builds->search({iscurrent => 1})) {
|
foreach my $build ($jobset->builds->search({iscurrent => 1})) {
|
||||||
print "current is ", $build->id, "\n";
|
|
||||||
$build->update({iscurrent => 0}) unless $currentBuilds{$build->id};
|
$build->update({iscurrent => 0}) unless $currentBuilds{$build->id};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue