diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2017-06-03 23:55:31 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2017-06-04 00:35:55 +0200 |
| commit | 2ca9f51ec8125c0124362300853365a1a6c76ee5 (patch) | |
| tree | 1b0fbd14a29dff3ea9fb077abb5483e7e9f0e4b8 | |
| parent | 20214f71157074406c19f4d29228eed79938b97d (diff) | |
daemon: Add '--timeout' and '--max-silent-time'.
* nix/nix-daemon/guix-daemon.cc (GUIX_OPT_TIMEOUT)
(GUIX_OPT_MAX_SILENT_TIME): New macros.
* nix/nix-daemon/guix-daemon.cc (options): Add '--timeout' and
'--max-silent-time'.
(parse_opt): Honor them.
* tests/guix-daemon.sh: Add test.
* doc/guix.texi (Invoking guix-daemon): Document the options.
(Common Build Options): Properly describe default
timeout/max-silent-time value. Add cross-ref to "Invoking
guix-daemon".
| -rw-r--r-- | doc/guix.texi | 25 | ||||
| -rw-r--r-- | nix/nix-daemon/guix-daemon.cc | 12 | ||||
| -rw-r--r-- | tests/guix-daemon.sh | 36 |
3 files changed, 71 insertions, 2 deletions
diff --git a/doc/guix.texi b/doc/guix.texi index aabb99039a7..9dde022c543 100644 --- a/doc/guix.texi +++ b/doc/guix.texi | |||
| @@ -1146,6 +1146,24 @@ Allow at most @var{n} build jobs in parallel. The default value is | |||
| 1146 | locally; instead, the daemon will offload builds (@pxref{Daemon Offload | 1146 | locally; instead, the daemon will offload builds (@pxref{Daemon Offload |
| 1147 | Setup}), or simply fail. | 1147 | Setup}), or simply fail. |
| 1148 | 1148 | ||
| 1149 | @item --max-silent-time=@var{seconds} | ||
| 1150 | When the build or substitution process remains silent for more than | ||
| 1151 | @var{seconds}, terminate it and report a build failure. | ||
| 1152 | |||
| 1153 | The default value is @code{0}, which disables the timeout. | ||
| 1154 | |||
| 1155 | The value specified here can be overridden by clients (@pxref{Common | ||
| 1156 | Build Options, @code{--max-silent-time}}). | ||
| 1157 | |||
| 1158 | @item --timeout=@var{seconds} | ||
| 1159 | Likewise, when the build or substitution process lasts for more than | ||
| 1160 | @var{seconds}, terminate it and report a build failure. | ||
| 1161 | |||
| 1162 | The default value is @code{0}, which disables the timeout. | ||
| 1163 | |||
| 1164 | The value specified here can be overridden by clients (@pxref{Common | ||
| 1165 | Build Options, @code{--timeout}}). | ||
| 1166 | |||
| 1149 | @item --rounds=@var{N} | 1167 | @item --rounds=@var{N} |
| 1150 | Build each derivation @var{n} times in a row, and raise an error if | 1168 | Build each derivation @var{n} times in a row, and raise an error if |
| 1151 | consecutive build results are not bit-for-bit identical. Note that this | 1169 | consecutive build results are not bit-for-bit identical. Note that this |
| @@ -4940,12 +4958,15 @@ instead of offloading builds to remote machines. | |||
| 4940 | When the build or substitution process remains silent for more than | 4958 | When the build or substitution process remains silent for more than |
| 4941 | @var{seconds}, terminate it and report a build failure. | 4959 | @var{seconds}, terminate it and report a build failure. |
| 4942 | 4960 | ||
| 4961 | By default, the daemon's setting is honored (@pxref{Invoking | ||
| 4962 | guix-daemon, @code{--max-silent-time}}). | ||
| 4963 | |||
| 4943 | @item --timeout=@var{seconds} | 4964 | @item --timeout=@var{seconds} |
| 4944 | Likewise, when the build or substitution process lasts for more than | 4965 | Likewise, when the build or substitution process lasts for more than |
| 4945 | @var{seconds}, terminate it and report a build failure. | 4966 | @var{seconds}, terminate it and report a build failure. |
| 4946 | 4967 | ||
| 4947 | By default there is no timeout. This behavior can be restored with | 4968 | By default, the daemon's setting is honored (@pxref{Invoking |
| 4948 | @code{--timeout=0}. | 4969 | guix-daemon, @code{--timeout}}). |
| 4949 | 4970 | ||
| 4950 | @item --verbosity=@var{level} | 4971 | @item --verbosity=@var{level} |
| 4951 | Use the given verbosity level. @var{level} must be an integer between 0 | 4972 | Use the given verbosity level. @var{level} must be an integer between 0 |
diff --git a/nix/nix-daemon/guix-daemon.cc b/nix/nix-daemon/guix-daemon.cc index aa47a290d22..0d9c33d1d2e 100644 --- a/nix/nix-daemon/guix-daemon.cc +++ b/nix/nix-daemon/guix-daemon.cc | |||
| @@ -81,6 +81,8 @@ builds derivations on behalf of its clients."); | |||
| 81 | #define GUIX_OPT_GC_KEEP_OUTPUTS 15 | 81 | #define GUIX_OPT_GC_KEEP_OUTPUTS 15 |
| 82 | #define GUIX_OPT_GC_KEEP_DERIVATIONS 16 | 82 | #define GUIX_OPT_GC_KEEP_DERIVATIONS 16 |
| 83 | #define GUIX_OPT_BUILD_ROUNDS 17 | 83 | #define GUIX_OPT_BUILD_ROUNDS 17 |
| 84 | #define GUIX_OPT_TIMEOUT 18 | ||
| 85 | #define GUIX_OPT_MAX_SILENT_TIME 19 | ||
| 84 | 86 | ||
| 85 | static const struct argp_option options[] = | 87 | static const struct argp_option options[] = |
| 86 | { | 88 | { |
| @@ -91,6 +93,10 @@ static const struct argp_option options[] = | |||
| 91 | }, | 93 | }, |
| 92 | { "max-jobs", 'M', n_("N"), 0, | 94 | { "max-jobs", 'M', n_("N"), 0, |
| 93 | n_("allow at most N build jobs") }, | 95 | n_("allow at most N build jobs") }, |
| 96 | { "timeout", GUIX_OPT_TIMEOUT, n_("SECONDS"), 0, | ||
| 97 | n_("mark builds as failed after SECONDS of activity") }, | ||
| 98 | { "max-silent-time", GUIX_OPT_MAX_SILENT_TIME, n_("SECONDS"), 0, | ||
| 99 | n_("mark builds as failed after SECONDS of silence") }, | ||
| 94 | { "disable-chroot", GUIX_OPT_DISABLE_CHROOT, 0, 0, | 100 | { "disable-chroot", GUIX_OPT_DISABLE_CHROOT, 0, 0, |
| 95 | n_("disable chroot builds") }, | 101 | n_("disable chroot builds") }, |
| 96 | { "chroot-directory", GUIX_OPT_CHROOT_DIR, n_("DIR"), 0, | 102 | { "chroot-directory", GUIX_OPT_CHROOT_DIR, n_("DIR"), 0, |
| @@ -245,6 +251,12 @@ parse_opt (int key, char *arg, struct argp_state *state) | |||
| 245 | case 'M': | 251 | case 'M': |
| 246 | settings.set ("build-max-jobs", arg); | 252 | settings.set ("build-max-jobs", arg); |
| 247 | break; | 253 | break; |
| 254 | case GUIX_OPT_TIMEOUT: | ||
| 255 | settings.set ("build-timeout", arg); | ||
| 256 | break; | ||
| 257 | case GUIX_OPT_MAX_SILENT_TIME: | ||
| 258 | settings.set ("build-max-silent-time", arg); | ||
| 259 | break; | ||
| 248 | case GUIX_OPT_SYSTEM: | 260 | case GUIX_OPT_SYSTEM: |
| 249 | settings.thisSystem = arg; | 261 | settings.thisSystem = arg; |
| 250 | break; | 262 | break; |
diff --git a/tests/guix-daemon.sh b/tests/guix-daemon.sh index fde49e25a2f..9186ffd5858 100644 --- a/tests/guix-daemon.sh +++ b/tests/guix-daemon.sh | |||
| @@ -145,3 +145,39 @@ guile -c ' | |||
| 145 | (exit | 145 | (exit |
| 146 | (= 42 (pk (call-with-input-file (derivation->output-path drv) | 146 | (= 42 (pk (call-with-input-file (derivation->output-path drv) |
| 147 | read)))))))' | 147 | read)))))))' |
| 148 | |||
| 149 | |||
| 150 | kill "$daemon_pid" | ||
| 151 | |||
| 152 | # Make sure the daemon's default 'timeout' and 'max-silent-time' settings are | ||
| 153 | # honored. | ||
| 154 | |||
| 155 | client_code=' | ||
| 156 | (use-modules (guix) (gnu packages) (guix tests) (srfi srfi-34)) | ||
| 157 | |||
| 158 | (with-store store | ||
| 159 | (let* ((build (add-text-to-store store "build.sh" | ||
| 160 | "while true ; do : ; done")) | ||
| 161 | (bash (add-to-store store "bash" #t "sha256" | ||
| 162 | (search-bootstrap-binary "bash" | ||
| 163 | (%current-system)))) | ||
| 164 | (drv (derivation store "the-thing" bash | ||
| 165 | `("-e" ,build) | ||
| 166 | #:inputs `((,bash) (,build)) | ||
| 167 | #:env-vars `(("x" . ,(random-text)))))) | ||
| 168 | (exit (guard (c ((nix-protocol-error? c) | ||
| 169 | (->bool | ||
| 170 | (string-contains (pk (nix-protocol-error-message c)) | ||
| 171 | "failed")))) | ||
| 172 | (build-derivations store (list drv)) | ||
| 173 | #f))))' | ||
| 174 | |||
| 175 | |||
| 176 | for option in --max-silent-time=1 --timeout=1 | ||
| 177 | do | ||
| 178 | guix-daemon --listen="$socket" --disable-chroot "$option" & | ||
| 179 | daemon_pid=$! | ||
| 180 | |||
| 181 | GUIX_DAEMON_SOCKET="$socket" guile -c "$client_code" | ||
| 182 | kill "$daemon_pid" | ||
| 183 | done | ||
