[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/01: daemon: Add '--timeout' and '--max-silent-time'.
From: |
Ludovic Courtès |
Subject: |
01/01: daemon: Add '--timeout' and '--max-silent-time'. |
Date: |
Sat, 3 Jun 2017 18:36:02 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 2ca9f51ec8125c0124362300853365a1a6c76ee5
Author: Ludovic Courtès <address@hidden>
Date: Sat Jun 3 23:55:31 2017 +0200
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".
---
doc/guix.texi | 25 +++++++++++++++++++++++--
nix/nix-daemon/guix-daemon.cc | 12 ++++++++++++
tests/guix-daemon.sh | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 71 insertions(+), 2 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index aabb990..9dde022 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
locally; instead, the daemon will offload builds (@pxref{Daemon Offload
Setup}), or simply fail.
address@hidden address@hidden
+When the build or substitution process remains silent for more than
address@hidden, terminate it and report a build failure.
+
+The default value is @code{0}, which disables the timeout.
+
+The value specified here can be overridden by clients (@pxref{Common
+Build Options, @code{--max-silent-time}}).
+
address@hidden address@hidden
+Likewise, when the build or substitution process lasts for more than
address@hidden, terminate it and report a build failure.
+
+The default value is @code{0}, which disables the timeout.
+
+The value specified here can be overridden by clients (@pxref{Common
+Build Options, @code{--timeout}}).
+
@item address@hidden
Build each derivation @var{n} times in a row, and raise an error if
consecutive build results are not bit-for-bit identical. Note that this
@@ -4940,12 +4958,15 @@ instead of offloading builds to remote machines.
When the build or substitution process remains silent for more than
@var{seconds}, terminate it and report a build failure.
+By default, the daemon's setting is honored (@pxref{Invoking
+guix-daemon, @code{--max-silent-time}}).
+
@item address@hidden
Likewise, when the build or substitution process lasts for more than
@var{seconds}, terminate it and report a build failure.
-By default there is no timeout. This behavior can be restored with
address@hidden
+By default, the daemon's setting is honored (@pxref{Invoking
+guix-daemon, @code{--timeout}}).
@item address@hidden
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 aa47a29..0d9c33d 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.");
#define GUIX_OPT_GC_KEEP_OUTPUTS 15
#define GUIX_OPT_GC_KEEP_DERIVATIONS 16
#define GUIX_OPT_BUILD_ROUNDS 17
+#define GUIX_OPT_TIMEOUT 18
+#define GUIX_OPT_MAX_SILENT_TIME 19
static const struct argp_option options[] =
{
@@ -91,6 +93,10 @@ static const struct argp_option options[] =
},
{ "max-jobs", 'M', n_("N"), 0,
n_("allow at most N build jobs") },
+ { "timeout", GUIX_OPT_TIMEOUT, n_("SECONDS"), 0,
+ n_("mark builds as failed after SECONDS of activity") },
+ { "max-silent-time", GUIX_OPT_MAX_SILENT_TIME, n_("SECONDS"), 0,
+ n_("mark builds as failed after SECONDS of silence") },
{ "disable-chroot", GUIX_OPT_DISABLE_CHROOT, 0, 0,
n_("disable chroot builds") },
{ "chroot-directory", GUIX_OPT_CHROOT_DIR, n_("DIR"), 0,
@@ -245,6 +251,12 @@ parse_opt (int key, char *arg, struct argp_state *state)
case 'M':
settings.set ("build-max-jobs", arg);
break;
+ case GUIX_OPT_TIMEOUT:
+ settings.set ("build-timeout", arg);
+ break;
+ case GUIX_OPT_MAX_SILENT_TIME:
+ settings.set ("build-max-silent-time", arg);
+ break;
case GUIX_OPT_SYSTEM:
settings.thisSystem = arg;
break;
diff --git a/tests/guix-daemon.sh b/tests/guix-daemon.sh
index fde49e2..9186ffd 100644
--- a/tests/guix-daemon.sh
+++ b/tests/guix-daemon.sh
@@ -145,3 +145,39 @@ guile -c '
(exit
(= 42 (pk (call-with-input-file (derivation->output-path drv)
read)))))))'
+
+
+kill "$daemon_pid"
+
+# Make sure the daemon's default 'timeout' and 'max-silent-time' settings are
+# honored.
+
+client_code='
+ (use-modules (guix) (gnu packages) (guix tests) (srfi srfi-34))
+
+ (with-store store
+ (let* ((build (add-text-to-store store "build.sh"
+ "while true ; do : ; done"))
+ (bash (add-to-store store "bash" #t "sha256"
+ (search-bootstrap-binary "bash"
+ (%current-system))))
+ (drv (derivation store "the-thing" bash
+ `("-e" ,build)
+ #:inputs `((,bash) (,build))
+ #:env-vars `(("x" . ,(random-text))))))
+ (exit (guard (c ((nix-protocol-error? c)
+ (->bool
+ (string-contains (pk (nix-protocol-error-message c))
+ "failed"))))
+ (build-derivations store (list drv))
+ #f))))'
+
+
+for option in --max-silent-time=1 --timeout=1
+do
+ guix-daemon --listen="$socket" --disable-chroot "$option" &
+ daemon_pid=$!
+
+ GUIX_DAEMON_SOCKET="$socket" guile -c "$client_code"
+ kill "$daemon_pid"
+done