* Keep the most recent builds for each job.

[?]
Feb 6, 2009, 2:17 PM
4X6NS66QDWR4S4ZZFKN2QOJQII5ZYIMTDYRHK25N6NJSROVLHJ6QC

Dependencies

  • [2] WZ3AEJ67 * hydra_update_gc_roots.pl registers build outputs that should be kept
  • [*] N22GPKYT * Put info about logs / build products in the DB.
  • [*] FHF6IZJQ * Basic release management: releases are now dynamically computed as

Change contents

  • edit in src/Hydra/script/hydra_update_gc_roots.pl at line 8
    [2.607]
    [2.607]
    use POSIX qw(strftime);
  • replacement in src/Hydra/script/hydra_update_gc_roots.pl at line 20
    [2.795][2.795:816]()
    print "$path\n";
    [2.795]
    [2.816]
    #print "$path\n";
  • replacement in src/Hydra/script/hydra_update_gc_roots.pl at line 26
    [2.919][2.919:940]()
    if (!-e $link) {
    [2.919]
    [2.940]
    if (!-l $link) {
  • replacement in src/Hydra/script/hydra_update_gc_roots.pl at line 28
    [2.970][2.970:1040]()
    or die "cannot creating symlink in $gcRootsDir to $path";
    [2.970]
    [2.1040]
    or die "cannot create symlink in $gcRootsDir to $path";
  • replacement in src/Hydra/script/hydra_update_gc_roots.pl at line 35
    [2.1074][2.1074:1139]()
    # Determine which builds to keep automatically.
    my %pathsToKeep;
    [2.1074]
    [2.1139]
    sub keepBuild {
    my ($build) = @_;
    print "keeping build ", $build->id, " (",
    strftime("%Y-%m-%d %H:%M:%S", localtime($build->timestamp)), ")\n";
    if (isValidPath($build->outpath)) {
    registerRoot $build->outpath;
    } else {
    print STDERR "warning: output ", $build->outpath, " has disappeared\n";
    }
    }
  • edit in src/Hydra/script/hydra_update_gc_roots.pl at line 46
    [2.1140][2.1140:1147]()
    # TODO
  • edit in src/Hydra/script/hydra_update_gc_roots.pl at line 47
    [2.1148]
    [2.1148]
    # Go over all jobs in all projects.
  • replacement in src/Hydra/script/hydra_update_gc_roots.pl at line 49
    [2.1149][2.1149:1610]()
    # For finished builds, we only keep the output path, not the derivation.
    foreach my $build ($db->resultset('Builds')->search({finished => 1, buildStatus => 0}, {join => 'resultInfo'})) {
    if ($build->resultInfo->keep || defined $pathsToKeep{$build->outpath}) {
    if (isValidPath($build->outpath)) {
    registerRoot $build->outpath;
    } else {
    print STDERR "warning: output ", $build->outpath, " has disappeared\n";
    }
    [2.1149]
    [2.1610]
    foreach my $project ($db->resultset('Projects')->all) {
    foreach my $job ($project->builds->search({},
    {select => [{distinct => 'attrname'}], as => ['attrname']}))
    {
    print "*** looking for builds to keep in ", $project->name, ":", $job->attrname, "\n";
    # Keep the N most recent successful builds for each job and
    # platform.
    my @recentBuilds = $project->builds->search(
    { attrname => $job->attrname
    , finished => 1
    , buildStatus => 0 # == success
    },
    { join => 'resultInfo'
    , order_by => 'timestamp DESC'
    , rows => 3 # !!! should make this configurable
    });
    keepBuild $_ foreach @recentBuilds;
  • edit in src/Hydra/script/hydra_update_gc_roots.pl at line 73
    [2.1620]
    [2.1620]
    # Keep all builds that have been marked as "keep".
    print "*** looking for kept builds\n";
    my @buildsToKeep = $db->resultset('Builds')->search({finished => 1, keep => 1}, {join => 'resultInfo'});
    keepBuild $_ foreach @buildsToKeep;
  • edit in src/Hydra/script/hydra_update_gc_roots.pl at line 80
    [2.1685]
    [2.1685]
    print "*** looking for scheduled builds\n";
  • edit in src/Hydra/sql/hydra.sql at line 343
    [5.12735]
    [5.12735]
    -- !!! urgh: "release" is a reserved keyword in sqlite >= 3.6.8!