Add a jobset eval action to restart all aborted/cancelled builds

[?]
Oct 4, 2013, 3:01 PM
VHV6GI4L2GEV2PV3AEV4C22O3JB4XUS6WPEBFINYD5CJOBMAESAAC

Dependencies

  • [2] ZH6B56XR Try harder to find build logs
  • [3] AWMM5OGV Use delete instead of delete_all
  • [4] UOINKJ2J Add an action to cancel all builds in a jobset eval
  • [5] HPEG2RHV Merge the BuildResultInfo table into the Builds table
  • [6] YDVFPMKP Security: Ensure that a build product refers to the Nix store
  • [7] MOX7XJ2E Merge the BuildSchedulingInfo table into the Builds table
  • [8] GEADFVZ5 hydra-queue-runner: Improved scheduling
  • [9] R6B5CAFF Let Builds.timestamp refer to the time the build was added
  • [10] A52HEFHQ * Allow builds to be restarted (if they failed with a transient error,
  • [11] QEC5HR4R Always record inputs passed through -I in the BuildInputs table
  • [12] ZILILXXK * Allow scheduled builds to be cancelled. They're not removed from
  • [13] LZVO64YG Merge in the first bits of the API work
  • [14] BDSD2JLV * Speed up manifest generation.
  • [15] PMNWRTGJ Add multiple output support
  • [16] GJFYEU3S * Nix now stores logs by default as bzip2, make sure the build page uncompresses before showing.
  • [17] KLSDJV75 Serve raw uncompressed logs directly
  • [18] 2UZJG6XT Clear nrSucceeded when restarting a build
  • [19] NLJJZVHO * Use ->update({...}) properly.
  • [20] JIJDYWPY Remove the Build menu from the top bar
  • [21] 3XTHEUMP * Implemented the clone feature.
  • [22] CQTN62OH Die tabs die
  • [23] SKQXOQ7T hydra: fixed missing argument to restartbuild function
  • [24] OSVLMLCQ hydra: factored out build restart and
  • [*] LBNVQXUB * Build the /build stuff in a separate controller.
  • [*] U4TD3AIQ Add support for viewing jobset evaluations
  • [*] OOQ2D3KC * Refactoring: move fetchInput out of hydra_scheduler into a separate
  • [*] 2GK5DOU7 * Downloading closures.
  • [*] TJK27WSB Open the DB using Hydra::Model::DB->new
  • [*] AFTXA575 * $HYDRA_DATA environment variable.
  • [*] 6HWHYPSW Add an action menu to evaluations

Change contents

  • edit in src/lib/Hydra/Controller/Build.pm at line 440
    [5.146][5.146:147]()
  • edit in src/lib/Hydra/Controller/Build.pm at line 441
    [5.183][5.183:184]()
  • replacement in src/lib/Hydra/Controller/Build.pm at line 442
    [5.230][5.621:622](),[5.35][5.41:90](),[5.41][5.41:90](),[5.90][5.0:55](),[5.55][5.521:522](),[5.84][5.521:522](),[5.139][5.521:522](),[5.521][5.521:522](),[5.522][5.0:51](),[5.51][5.756:757](),[5.166][5.756:757](),[5.756][5.756:757]()
    error($c, "This build cannot be restarted.")
    unless $build->finished && -f $build->drvpath;
    restartBuild($c->model('DB')->schema, $build);
    [5.230]
    [4.188]
    my $n = restartBuilds($c->model('DB')->schema, $c->model('DB::Builds')->search({ id => $build->id }));
    error($c, "This build cannot be restarted.") if $n != 1;
  • edit in src/lib/Hydra/Controller/Build.pm at line 445
    [4.247][5.623:624](),[5.363][5.623:624]()
  • edit in src/lib/Hydra/Controller/JobsetEval.pm at line 162
    [4.950]
    [4.950]
    $c->res->redirect($c->uri_for($c->controller('JobsetEval')->action_for('view'), $c->req->captures));
    }
    sub restart_aborted : Chained('eval') PathPart('restart-aborted') Args(0) {
    my ($self, $c) = @_;
    requireProjectOwner($c, $c->stash->{eval}->project);
    my $builds = $c->stash->{eval}->builds->search({ finished => 1, buildstatus => { -in => [3, 4] } });
    my $n = restartBuilds($c->model('DB')->schema, $builds);
    $c->flash->{successMsg} = "$n builds have been restarted.";
  • edit in src/lib/Hydra/Helper/AddBuilds.pm at line 554
    [5.6996][5.308:379](),[5.379][5.9256:9374]()
    sub restartBuild {
    my ($db, $build) = @_;
    txn_do($db, sub {
    my @paths;
    push @paths, $build->drvpath;
    push @paths, $_->drvpath foreach $build->buildsteps;
  • edit in src/lib/Hydra/Helper/AddBuilds.pm at line 555
    [5.460][5.9375:9432]()
    my $r = `nix-store --clear-failed-paths @paths`;
  • replacement in src/lib/Hydra/Helper/AddBuilds.pm at line 556
    [5.716][5.3113:3137](),[5.3137][5.4716:4744](),[5.3183][5.913:964](),[5.4776][5.913:964](),[5.913][5.913:964](),[5.964][5.527:560](),[5.560][5.4777:4793](),[5.964][5.4777:4793](),[5.4793][5.561:562](),[5.562][3.561:600](),[3.600][5.85:319](),[5.605][5.85:319](),[5.4793][5.85:319](),[5.3193][5.85:319](),[5.319][5.980:990](),[5.3230][5.980:990](),[5.980][5.980:990]()
    $build->update(
    { finished => 0
    , busy => 0
    , locker => ""
    , iscachedbuild => 0
    });
    $build->buildproducts->delete;
    # Reset the stats for the evals to which this build belongs.
    # !!! Should do this in a trigger.
    foreach my $m ($build->jobsetevalmembers->all) {
    $m->eval->update({nrsucceeded => undef});
    }
    });
    }
    [5.589]
    1;
  • edit in src/lib/Hydra/Helper/Nix.pm at line 10
    [30.99]
    [31.127]
    use Nix::Store;
  • replacement in src/lib/Hydra/Helper/Nix.pm at line 26
    [4.1079][4.1079:1098]()
    cancelBuilds);
    [4.1079]
    [5.77]
    cancelBuilds restartBuilds);
  • replacement in src/lib/Hydra/Helper/Nix.pm at line 278
    [2.1698][2.1698:1703]()
    [2.1698]
    [2.1703]
  • edit in src/lib/Hydra/Helper/Nix.pm at line 561
    [4.1608]
    [4.1608]
    });
    }
    sub restartBuilds($$) {
    my ($db, $builds) = @_;
    my $n = 0;
    txn_do($db, sub {
    my @paths;
    $builds = $builds->search({ finished => 1 });
    foreach my $build ($builds->all) {
    next if !isValidPath($build->drvpath);
    push @paths, $build->drvpath;
    push @paths, $_->drvpath foreach $build->buildsteps;
    $build->update(
    { finished => 0
    , busy => 0
    , locker => ""
    , iscachedbuild => 0
    });
    $n++;
    # Reset the stats for the evals to which this build belongs.
    # !!! Should do this in a trigger.
    $build->jobsetevals->update({nrsucceeded => undef});
    }
    # Clear Nix's negative failure cache.
    # FIXME: Add this to the API.
    system("nix-store", "--clear-failed-paths", @paths);
  • edit in src/lib/Hydra/Helper/Nix.pm at line 595
    [4.1616]
    [4.1616]
    return $n;
  • edit in src/root/jobset-eval.tt at line 46
    [4.1756]
    [32.353]
    <li><a href="[% c.uri_for(c.controller('JobsetEval').action_for('restart_aborted'), [eval.id]) %]">Restart all aborted builds</a></li>