From f353a7ac41933b376c282b6928b74d3c5e591add Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Sat, 19 Mar 2022 23:12:28 -0400 Subject: [PATCH] update-gc-roots: try subselecting the jobset table --- src/script/hydra-update-gc-roots | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/script/hydra-update-gc-roots b/src/script/hydra-update-gc-roots index f446cdf9..8cf24d5d 100755 --- a/src/script/hydra-update-gc-roots +++ b/src/script/hydra-update-gc-roots @@ -37,8 +37,6 @@ sub keepBuild { return if defined $seenBuilds{$build->id}; $seenBuilds{$build->id} = 1; - $build->finished; - my ($jobset) = $build->jobset; print STDERR " keeping ", ($build->finished ? "" : "scheduled "), "build ", $build->id, " (", @@ -76,13 +74,29 @@ closedir $dir; # For scheduled builds, we register the derivation as a GC root. print STDERR "*** looking for scheduled builds\n"; -keepBuild($_, 0) foreach $db->resultset('Builds')->search({ finished => 0 }, { columns => [ @columns ] }); +keepBuild($_, 0) foreach $db->resultset('Builds')->search( + { finished => 0 }, + { + columns => [ @columns ], + join => 'jobset', + '+select' => ['jobset.project', 'jobset.name'], + '+as' => ['jobset.project', 'jobset.name'], + } +); # Keep all builds that have been marked as "keep". print STDERR "*** looking for kept builds\n"; my @buildsToKeep = $db->resultset('Builds')->search( - { finished => 1, keep => 1 }, { order_by => ["jobset_id", "job", "id"], columns => [ @columns ] }); + { finished => 1, keep => 1 }, + { + order_by => ["jobset_id", "job", "id"], + columns => [ @columns ], + join => 'jobset', + '+select' => ['jobset.project', 'jobset.name'], + '+as' => ['jobset.project', 'jobset.name'], + } +); keepBuild($_, 0) foreach @buildsToKeep;