add option to disable retry on transient build failure

Open
#640 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
30/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale
Tech stack
cpp

Research direction

Start in src/hydra-queue-runner/build-remote.cc at the BuildResult::TransientFailure branch shown in the issue. Verify how the derivation environment is read and confirm that __hydraRetry=false stops retries after the first transient failure while the default behavior remains unchanged.

Written by the indexing model from the issue text.

Description

When Nix returns BuildResult::TransientFailure, Hydra retries the build many times with exponential back-off. This is appropriate when the derivation is simply downloading from the internet, but Nix actually returns this error code quite liberally, and it does it systematically for fixed-output and impure derivations when they fail.

This behavior is sometimes very unwelcome; for example, I am using dedicated fixed-output derivations to run additional, complex tests that involve hardware-in-the-loop and Windows VMs.

The simple patch below allows retries to be disabled for particular derivations in this manner:

    foo = pkgs.stdenv.mkDerivation {
      outputHashAlgo = "sha256";
      outputHashMode = "recursive";
      outputHash = "...";
      __hydraRetry = false;
      ...
    }

When the build of that derivation fails, Hydra immediately marks it as failed after the first attempt.

commit cbdd0167ac1dbd1bfb96a7d7cdeefe01af8599cd (HEAD -> patched-npm, origin/patched-npm)
Author: Sebastien Bourdeauducq <sb@m-labs.hk>
Date:   Thu Mar 14 17:45:32 2019 +0800

    add option to disable retries on transient failures

diff --git a/src/hydra-queue-runner/build-remote.cc b/src/hydra-queue-runner/build-remote.cc
index 69c430eb..bdbc808d 100644
--- a/src/hydra-queue-runner/build-remote.cc
+++ b/src/hydra-queue-runner/build-remote.cc
@@ -344,7 +344,7 @@ void State::buildRemote(ref<Store> destStore,
                     break;
                 case BuildResult::TransientFailure:
                     result.stepStatus = bsFailed;
-                    result.canRetry = true;
+                    result.canRetry = get(step->drv.env, "__hydraRetry", "1") == "1";
                     result.errorMsg = "";
                     break;
                 case BuildResult::TimedOut:
Dominant language
PLpgSQL
Stars
1.6k
Forks
358
Avg merge
20h 30m
Merged PRs (30d)
27

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NixOS/hydra

All issues in NixOS/hydra

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.