When manually scheduling an eval, force re-instantiation of store derivations

Without this, if (failed or aborted) derivations have been
garbage-collected, there is no way to restart them, which is very
annoying. Now we set a forceEval flag in the jobset to cause it to be
re-evaluated even if none of the inputs have changed.
This commit is contained in:
Eelco Dolstra 2016-10-24 20:20:20 +02:00
parent 140cbe9302
commit a12e9478e7
5 changed files with 18 additions and 8 deletions

View file

@ -202,10 +202,11 @@ sub scmdiff : Chained('api') PathPart('scmdiff') Args(0) {
sub triggerJobset { sub triggerJobset {
my ($self, $c, $jobset) = @_; my ($self, $c, $jobset, $force) = @_;
print STDERR "triggering jobset ", $jobset->project->name . ":" . $jobset->name, "\n"; print STDERR "triggering jobset ", $jobset->project->name . ":" . $jobset->name, "\n";
txn_do($c->model('DB')->schema, sub { txn_do($c->model('DB')->schema, sub {
$jobset->update({ triggertime => time }); $jobset->update({ triggertime => time });
$jobset->update({ forceeval => 1 }) if $force;
}); });
push @{$c->{stash}->{json}->{jobsetsTriggered}}, $jobset->project->name . ":" . $jobset->name; push @{$c->{stash}->{json}->{jobsetsTriggered}}, $jobset->project->name . ":" . $jobset->name;
} }
@ -222,12 +223,12 @@ sub push : Chained('api') PathPart('push') Args(0) {
my ($p, $j) = parseJobsetName($s); my ($p, $j) = parseJobsetName($s);
my $jobset = $c->model('DB::Jobsets')->find($p, $j); my $jobset = $c->model('DB::Jobsets')->find($p, $j);
next unless defined $jobset && ($force || ($jobset->project->enabled && $jobset->enabled)); next unless defined $jobset && ($force || ($jobset->project->enabled && $jobset->enabled));
triggerJobset($self, $c, $jobset); triggerJobset($self, $c, $jobset, $force);
} }
my @repos = split /,/, ($c->request->query_params->{repos} // ""); my @repos = split /,/, ($c->request->query_params->{repos} // "");
foreach my $r (@repos) { foreach my $r (@repos) {
triggerJobset($self, $c, $_) foreach $c->model('DB::Jobsets')->search( triggerJobset($self, $c, $_, $force) foreach $c->model('DB::Jobsets')->search(
{ 'project.enabled' => 1, 'me.enabled' => 1 }, { 'project.enabled' => 1, 'me.enabled' => 1 },
{ join => 'project' { join => 'project'
, where => \ [ 'exists (select 1 from JobsetInputAlts where project = me.project and jobset = me.name and value = ?)', [ 'value', $r ] ] , where => \ [ 'exists (select 1 from JobsetInputAlts where project = me.project and jobset = me.name and value = ?)', [ 'value', $r ] ]
@ -251,7 +252,7 @@ sub push_github : Chained('api') PathPart('push-github') Args(0) {
my $repo = $in->{repository}->{name} or die; my $repo = $in->{repository}->{name} or die;
print STDERR "got push from GitHub repository $owner/$repo\n"; print STDERR "got push from GitHub repository $owner/$repo\n";
triggerJobset($self, $c, $_) foreach $c->model('DB::Jobsets')->search( triggerJobset($self, $c, $_, 0) foreach $c->model('DB::Jobsets')->search(
{ 'project.enabled' => 1, 'me.enabled' => 1 }, { 'project.enabled' => 1, 'me.enabled' => 1 },
{ join => 'project' { join => 'project'
, where => \ [ 'exists (select 1 from JobsetInputAlts where project = me.project and jobset = me.name and value like ?)', [ 'value', "%github.com%$owner/$repo%" ] ] , where => \ [ 'exists (select 1 from JobsetInputAlts where project = me.project and jobset = me.name and value like ?)', [ 'value', "%github.com%$owner/$repo%" ] ]

View file

@ -129,6 +129,11 @@ __PACKAGE__->table("Jobsets");
data_type: 'text' data_type: 'text'
is_nullable: 1 is_nullable: 1
=head2 forceeval
data_type: 'boolean'
is_nullable: 1
=cut =cut
__PACKAGE__->add_columns( __PACKAGE__->add_columns(
@ -166,6 +171,8 @@ __PACKAGE__->add_columns(
{ data_type => "integer", default_value => 100, is_nullable => 0 }, { data_type => "integer", default_value => 100, is_nullable => 0 },
"fetcherrormsg", "fetcherrormsg",
{ data_type => "text", is_nullable => 1 }, { data_type => "text", is_nullable => 1 },
"forceeval",
{ data_type => "boolean", is_nullable => 1 },
); );
=head1 PRIMARY KEY =head1 PRIMARY KEY
@ -338,8 +345,8 @@ __PACKAGE__->has_many(
); );
# Created by DBIx::Class::Schema::Loader v0.07043 @ 2015-07-30 16:52:20 # Created by DBIx::Class::Schema::Loader v0.07045 @ 2016-10-24 20:12:51
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Coci9FdBAvUO9T3st2NEqA # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:PSR66NnVRNTMFhDEm10erA
my %hint = ( my %hint = (
columns => [ columns => [

View file

@ -149,7 +149,7 @@ sub checkJobsetWrapped {
my @args = ($jobset->nixexprinput, $jobset->nixexprpath, inputsToArgs($inputInfo, $exprType)); my @args = ($jobset->nixexprinput, $jobset->nixexprpath, inputsToArgs($inputInfo, $exprType));
my $argsHash = sha256_hex("@args"); my $argsHash = sha256_hex("@args");
my $prevEval = getPrevJobsetEval($db, $jobset, 0); my $prevEval = getPrevJobsetEval($db, $jobset, 0);
if (defined $prevEval && $prevEval->hash eq $argsHash && !$dryRun) { if (defined $prevEval && $prevEval->hash eq $argsHash && !$dryRun && !$jobset->forceeval) {
print STDERR " jobset is unchanged, skipping\n"; print STDERR " jobset is unchanged, skipping\n";
Net::Statsd::increment("hydra.evaluator.unchanged_checkouts"); Net::Statsd::increment("hydra.evaluator.unchanged_checkouts");
txn_do($db, sub { txn_do($db, sub {
@ -279,7 +279,7 @@ sub checkJobsetWrapped {
# If this is a one-shot jobset, disable it now. # If this is a one-shot jobset, disable it now.
$jobset->update({ enabled => 0 }) if $jobset->enabled == 2; $jobset->update({ enabled => 0 }) if $jobset->enabled == 2;
$jobset->update({ lastcheckedtime => time }); $jobset->update({ lastcheckedtime => time, forceeval => undef });
}); });
my $dbStop = clock_gettime(CLOCK_REALTIME); my $dbStop = clock_gettime(CLOCK_REALTIME);

View file

@ -68,6 +68,7 @@ create table Jobsets (
checkInterval integer not null default 300, -- minimum time in seconds between polls (0 = disable polling) checkInterval integer not null default 300, -- minimum time in seconds between polls (0 = disable polling)
schedulingShares integer not null default 100, schedulingShares integer not null default 100,
fetchErrorMsg text, fetchErrorMsg text,
forceEval boolean,
check (schedulingShares > 0), check (schedulingShares > 0),
primary key (project, name), primary key (project, name),
foreign key (project) references Projects(name) on delete cascade on update cascade foreign key (project) references Projects(name) on delete cascade on update cascade

1
src/sql/upgrade-51.sql Normal file
View file

@ -0,0 +1 @@
alter table Jobsets add column forceEval boolean;