offload: Skip machines that are low on disk space.
Fixes <https://bugs.gnu.org/33378>. * guix/scripts/offload.scm (node-free-disk-space): New procedure. (%minimum-disk-space): New variable. (choose-build-machine): Call 'node-free-disk-space' and take it into account in addition to LOAD. (check-machine-status): Display the free disk space.
This commit is contained in:
parent
bbe66a530a
commit
63b0c3eacc
|
@ -321,6 +321,13 @@ hook."
|
||||||
(set-port-revealed! port 1)
|
(set-port-revealed! port 1)
|
||||||
port))
|
port))
|
||||||
|
|
||||||
|
(define (node-free-disk-space node)
|
||||||
|
"Return the free disk space, in bytes, in NODE's store."
|
||||||
|
(node-eval node
|
||||||
|
`(begin
|
||||||
|
(use-modules (guix build syscalls))
|
||||||
|
(free-disk-space ,(%store-prefix)))))
|
||||||
|
|
||||||
(define* (transfer-and-offload drv machine
|
(define* (transfer-and-offload drv machine
|
||||||
#:key
|
#:key
|
||||||
(inputs '())
|
(inputs '())
|
||||||
|
@ -392,6 +399,12 @@ MACHINE."
|
||||||
(build-requirements-features requirements)
|
(build-requirements-features requirements)
|
||||||
(build-machine-features machine))))
|
(build-machine-features machine))))
|
||||||
|
|
||||||
|
(define %minimum-disk-space
|
||||||
|
;; Minimum disk space required on the build machine for a build to be
|
||||||
|
;; offloaded. This keeps us from offloading to machines that are bound to
|
||||||
|
;; run out of disk space.
|
||||||
|
(* 100 (expt 2 20))) ;100 MiB
|
||||||
|
|
||||||
(define (node-load node)
|
(define (node-load node)
|
||||||
"Return the load on NODE. Return +∞ if NODE is misbehaving."
|
"Return the load on NODE. Return +∞ if NODE is misbehaving."
|
||||||
(let ((line (node-eval node
|
(let ((line (node-eval node
|
||||||
|
@ -486,9 +499,10 @@ slot (which must later be released with 'release-build-slot'), or #f and #f."
|
||||||
;; too costly to call it once for every machine.
|
;; too costly to call it once for every machine.
|
||||||
(let* ((session (false-if-exception (open-ssh-session best)))
|
(let* ((session (false-if-exception (open-ssh-session best)))
|
||||||
(node (and session (make-node session)))
|
(node (and session (make-node session)))
|
||||||
(load (and node (normalized-load best (node-load node)))))
|
(load (and node (normalized-load best (node-load node))))
|
||||||
|
(space (and node (node-free-disk-space node))))
|
||||||
(when session (disconnect! session))
|
(when session (disconnect! session))
|
||||||
(if (and node (< load 2.))
|
(if (and node (< load 2.) (>= space %minimum-disk-space))
|
||||||
(match others
|
(match others
|
||||||
(((machines slots) ...)
|
(((machines slots) ...)
|
||||||
;; Release slots from the uninteresting machines.
|
;; Release slots from the uninteresting machines.
|
||||||
|
@ -498,7 +512,13 @@ slot (which must later be released with 'release-build-slot'), or #f and #f."
|
||||||
;; eventually release it.
|
;; eventually release it.
|
||||||
(values best slot)))
|
(values best slot)))
|
||||||
(begin
|
(begin
|
||||||
;; BEST is overloaded, so try the next one.
|
;; BEST is unsuitable, so try the next one.
|
||||||
|
(when (and space (< space %minimum-disk-space))
|
||||||
|
(format (current-error-port)
|
||||||
|
"skipping machine '~a' because it is low \
|
||||||
|
on disk space (~,2f MiB free)~%"
|
||||||
|
(build-machine-name best)
|
||||||
|
(/ space (expt 2 20) 1.)))
|
||||||
(release-build-slot slot)
|
(release-build-slot slot)
|
||||||
(loop others)))))
|
(loop others)))))
|
||||||
(()
|
(()
|
||||||
|
@ -694,15 +714,17 @@ machine."
|
||||||
(let* ((session (open-ssh-session machine))
|
(let* ((session (open-ssh-session machine))
|
||||||
(node (make-node session))
|
(node (make-node session))
|
||||||
(uts (node-eval node '(uname)))
|
(uts (node-eval node '(uname)))
|
||||||
(load (node-load node)))
|
(load (node-load node))
|
||||||
|
(free (node-free-disk-space node)))
|
||||||
(disconnect! session)
|
(disconnect! session)
|
||||||
(format #t "~a~% kernel: ~a ~a~% architecture: ~a~%\
|
(format #t "~a~% kernel: ~a ~a~% architecture: ~a~%\
|
||||||
host name: ~a~% normalized load: ~a~%"
|
host name: ~a~% normalized load: ~a~% free disk space: ~,2f MiB~%"
|
||||||
(build-machine-name machine)
|
(build-machine-name machine)
|
||||||
(utsname:sysname uts) (utsname:release uts)
|
(utsname:sysname uts) (utsname:release uts)
|
||||||
(utsname:machine uts)
|
(utsname:machine uts)
|
||||||
(utsname:nodename uts)
|
(utsname:nodename uts)
|
||||||
load)))
|
load
|
||||||
|
(/ free (expt 2 20) 1.))))
|
||||||
machines)))
|
machines)))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue