[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/10: offload: Honor the build timeout internally.
From: |
Ludovic Courtès |
Subject: |
01/10: offload: Honor the build timeout internally. |
Date: |
Mon, 11 Jun 2018 09:19:18 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit a708de151c255712071e42e5c8284756b51768cd
Author: Ludovic Courtès <address@hidden>
Date: Mon Jun 11 11:42:59 2018 +0200
offload: Honor the build timeout internally.
* guix/scripts/offload.scm (call-with-timeout): New procedure.
(with-timeout): New macro.
(process-request): Use it around 'transfer-and-offload' call.
---
guix/scripts/offload.scm | 46 ++++++++++++++++++++++++++++++++++++++--------
1 file changed, 38 insertions(+), 8 deletions(-)
diff --git a/guix/scripts/offload.scm b/guix/scripts/offload.scm
index 56d6de6..fb61d7c 100644
--- a/guix/scripts/offload.scm
+++ b/guix/scripts/offload.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2015, 2016, 2017 Ludovic Courtès <address@hidden>
+;;; Copyright © 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <address@hidden>
;;; Copyright © 2017 Ricardo Wurmus <address@hidden>
;;;
;;; This file is part of GNU Guix.
@@ -494,6 +494,30 @@ slot (which must later be released with
'release-build-slot'), or #f and #f."
(()
(values #f #f))))))
+(define (call-with-timeout timeout drv thunk)
+ "Call THUNK and leave after TIMEOUT seconds. If TIMEOUT is #f, simply call
+THUNK. Use DRV as an indication of what we were building when the timeout
+expired."
+ (if (number? timeout)
+ (dynamic-wind
+ (lambda ()
+ (sigaction SIGALRM
+ (lambda _
+ ;; The exit code here will be 1, which guix-daemon will
+ ;; interpret as a transient failure.
+ (leave (G_ "timeout expired while offloading '~a'~%")
+ (derivation-file-name drv))))
+ (alarm timeout))
+ thunk
+ (lambda ()
+ (alarm 0)))
+ (thunk)))
+
+(define-syntax-rule (with-timeout timeout drv exp ...)
+ "Evaluate EXP... and leave after TIMEOUT seconds if EXP hasn't completed.
+If TIMEOUT is #f, simply evaluate EXP..."
+ (call-with-timeout timeout drv (lambda () exp ...)))
+
(define* (process-request wants-local? system drv features
#:key
print-build-trace? (max-silent-time 3600)
@@ -520,13 +544,18 @@ slot (which must later be released with
'release-build-slot'), or #f and #f."
(display "# accept\n")
(let ((inputs (string-tokenize (read-line)))
(outputs (string-tokenize (read-line))))
- (transfer-and-offload drv machine
- #:inputs inputs
- #:outputs outputs
- #:max-silent-time max-silent-time
- #:build-timeout build-timeout
- #:print-build-trace?
- print-build-trace?)))
+ ;; Even if BUILD-TIMEOUT is honored by MACHINE, there can
+ ;; be issues with the connection or deadlocks that could
+ ;; lead the 'guix offload' process to remain stuck forever.
+ ;; To avoid that, install a timeout here as well.
+ (with-timeout build-timeout drv
+ (transfer-and-offload drv machine
+ #:inputs inputs
+ #:outputs outputs
+ #:max-silent-time max-silent-time
+ #:build-timeout build-timeout
+ #:print-build-trace?
+ print-build-trace?))))
(lambda ()
(release-build-slot slot)))
@@ -755,6 +784,7 @@ This tool is meant to be used internally by
'guix-daemon'.\n"))
;;; eval: (put 'with-machine-lock 'scheme-indent-function 2)
;;; eval: (put 'with-file-lock 'scheme-indent-function 1)
;;; eval: (put 'with-error-to-port 'scheme-indent-function 1)
+;;; eval: (put 'with-timeout 'scheme-indent-function 2)
;;; End:
;;; offload.scm ends here
- branch master updated (14299d2 -> 8bf7f74), Ludovic Courtès, 2018/06/11
- 05/10: gnu: Add emacs-helm-ls-git., Ludovic Courtès, 2018/06/11
- 02/10: gnu: Add go-github-com-gorilla-mux., Ludovic Courtès, 2018/06/11
- 03/10: gnu: Add go-github-com-jonboulle-clockwork., Ludovic Courtès, 2018/06/11
- 07/10: gnu: Add emacs-helm-pass., Ludovic Courtès, 2018/06/11
- 06/10: gnu: Add emacs-helm-mu., Ludovic Courtès, 2018/06/11
- 01/10: offload: Honor the build timeout internally.,
Ludovic Courtès <=
- 08/10: gnu: Add emacs-image+., Ludovic Courtès, 2018/06/11
- 04/10: gnu: Add go-github-com-spf13-pflag., Ludovic Courtès, 2018/06/11
- 10/10: gnu: Add Add emacs-wgrep-helm., Ludovic Courtès, 2018/06/11
- 09/10: gnu: Add emacs-package-lint., Ludovic Courtès, 2018/06/11