hydra-update-gc-roots: get project and jobset information from the project and jobset tables

This commit is contained in:
Graham Christensen 2022-01-15 14:08:44 -05:00
parent 52dda56b99
commit 7544d4ff47

View file

@ -25,7 +25,7 @@ sub addRoot {
my @columns = my @columns =
( "id", "project", "jobset", "job", "system", "finished", "drvpath", "timestamp", "buildstatus" ( "id", "jobset_id", "job", "system", "finished", "drvpath", "timestamp", "buildstatus"
, { "outpaths" => \ "(select string_agg(path, ' ') from BuildOutputs where build = me.id)" } , { "outpaths" => \ "(select string_agg(path, ' ') from BuildOutputs where build = me.id)" }
); );
@ -35,8 +35,16 @@ sub keepBuild {
my ($build, $keepFailedDrvs) = @_; my ($build, $keepFailedDrvs) = @_;
return if defined $seenBuilds{$build->id}; return if defined $seenBuilds{$build->id};
$seenBuilds{$build->id} = 1; $seenBuilds{$build->id} = 1;
$build->finished;
# After #1093 merges this can become $build->jobset;
# However, with ->jobset being a column on master
# it seems DBIX gets a bit confused.
my ($jobset) = $build->search_related('jobset')->first;
print STDERR " keeping ", ($build->finished ? "" : "scheduled "), "build ", $build->id, " (", print STDERR " keeping ", ($build->finished ? "" : "scheduled "), "build ", $build->id, " (",
$build->get_column('project'), ":", $build->get_column('jobset'), ":", $build->get_column('job'), "; ", $jobset->get_column('project'), ":", $jobset->get_column('name'), ":", $build->get_column('job'), "; ",
$build->system, "; ", $build->system, "; ",
strftime("%Y-%m-%d %H:%M:%S", localtime($build->timestamp)), ")\n"; strftime("%Y-%m-%d %H:%M:%S", localtime($build->timestamp)), ")\n";
if (isLocalStore && if (isLocalStore &&
@ -76,7 +84,7 @@ keepBuild($_, 0) foreach $db->resultset('Builds')->search({ finished => 0 }, { c
# Keep all builds that have been marked as "keep". # Keep all builds that have been marked as "keep".
print STDERR "*** looking for kept builds\n"; print STDERR "*** looking for kept builds\n";
my @buildsToKeep = $db->resultset('Builds')->search( my @buildsToKeep = $db->resultset('Builds')->search(
{ finished => 1, keep => 1 }, { order_by => ["project", "jobset", "job", "id"], columns => [ @columns ] }); { finished => 1, keep => 1 }, { order_by => ["jobset_id", "job", "id"], columns => [ @columns ] });
keepBuild($_, 0) foreach @buildsToKeep; keepBuild($_, 0) foreach @buildsToKeep;