From d16738e1300a4efe7d7d1c3c44e6adf30b5716ef Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 16 Aug 2013 16:21:30 +0200 Subject: [PATCH] hydra-update-gc-roots: Keep the most recent evaluations We now keep all builds in the N most recent evaluations of a jobset, rather than the N most recent builds of every job. Note that this means that typically fewer builds will be kept (since jobs may be unchanged across evaluations). --- src/root/edit-jobset.tt | 2 +- src/root/jobset.tt | 2 +- src/script/hydra-update-gc-roots | 22 +++++++++------------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/root/edit-jobset.tt b/src/root/edit-jobset.tt index efac4790..c7c98e95 100644 --- a/src/root/edit-jobset.tt +++ b/src/root/edit-jobset.tt @@ -110,7 +110,7 @@
- +
jobset.keepnr) %]>
diff --git a/src/root/jobset.tt b/src/root/jobset.tt index 156ef5df..13db0e3d 100644 --- a/src/root/jobset.tt +++ b/src/root/jobset.tt @@ -133,7 +133,7 @@ [% HTML.escape(jobset.emailoverride) %] - Number of builds to keep: + Number of evaluations to keep: [% jobset.keepnr %] diff --git a/src/script/hydra-update-gc-roots b/src/script/hydra-update-gc-roots index 43b17a4b..75475c42 100755 --- a/src/script/hydra-update-gc-roots +++ b/src/script/hydra-update-gc-roots @@ -89,20 +89,16 @@ foreach my $project ($db->resultset('Projects')->search({}, { order_by => ["name next; } - # FIXME: base this on jobset evals? - print STDERR "*** looking for the $keepnr most recent successful builds of each job in jobset ", + print STDERR "*** looking for all builds in the $keepnr most recent evaluations of jobset ", $project->name, ":", $jobset->name, "\n"; - keepBuild $_ foreach $jobset->builds->search( - { 'me.id' => { 'in' => \ - [ "select b2.id from Builds b2 join " . - " (select distinct job, system, coalesce( " . - " (select id from builds where project = b.project and jobset = b.jobset and job = b.job and system = b.system and finished = 1 and buildStatus = 0 order by id desc offset ? limit 1)" . - " , 0) as nth from builds b where project = ? and jobset = ? and isCurrent = 1) x " . - " on b2.project = ? and b2.jobset = ? and b2.job = x.job and b2.system = x.system and (id >= x.nth) where finished = 1 and buildStatus = 0" - , [ '', $keepnr - 1 ], [ '', $project->name ], [ '', $jobset->name ], [ '', $project->name ], [ '', $jobset->name ] ] } - }, - { order_by => ["job", "system", "id"], columns => [ @columns ] }); + keepBuild $_ foreach $jobset->builds->search( + { finished => 1, buildStatus => 0 + , id => { -in => + \ [ "select build from JobsetEvalMembers where eval in (select id from JobsetEvals where project = ? and jobset = ? and hasNewBuilds = 1 order by id desc limit ?)", + [ '', $project->name ], [ '', $jobset->name ], [ '', $keepnr ] ] } + }, + { order_by => ["job", "id"], columns => [ @columns ] }); } # Go over all views in this project. @@ -115,7 +111,7 @@ foreach my $project ($db->resultset('Projects')->search({}, { order_by => ["name # Keep all builds belonging to the most recent successful view result. my $latest = getLatestSuccessfulViewResult($project, $primaryJob, $jobs, 0); if (defined $latest) { - print STDERR " keeping latest successful view result ", $latest->id, " (", $latest->get_column('releasename'), ")\n"; + print STDERR " keeping latest successful view result ", $latest->id, " (", $latest->get_column('releasename') // "unnamed", ")\n"; my $result = getViewResult($latest, $jobs); keepBuild $_->{build} foreach @{$result->{jobs}}; }