offload: 'test' reports Guile and module errors more nicely.

Fixes <https://bugs.gnu.org/26008>.
Reported by Myles English <mylesenglish@gmail.com>.

* guix/ssh.scm (retrieve-files*): Move error reporting to...
(report-guile-error, report-module-error): ... here.  New procedures.
* guix/scripts/offload.scm (assert-node-repl): Use 'report-guile-error'.
(assert-node-has-guix): Explicitly check for 'use-modules' first.  Use
'report-module-error'.
This commit is contained in:
Ludovic Courtès 2018-01-12 23:16:53 +01:00
parent 5a5e34e358
commit 4eb0f9ae05
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
2 changed files with 40 additions and 18 deletions

View File

@ -542,8 +542,7 @@ slot (which must later be released with 'release-build-slot'), or #f and #f."
"Bail out if NODE is not running Guile." "Bail out if NODE is not running Guile."
(match (node-guile-version node) (match (node-guile-version node)
(#f (#f
(leave (G_ "Guile could not be started on '~a'~%") (report-guile-error name))
name))
((? string? version) ((? string? version)
;; Note: The version string already contains the word "Guile". ;; Note: The version string already contains the word "Guile".
(info (G_ "'~a' is running ~a~%") (info (G_ "'~a' is running ~a~%")
@ -551,6 +550,17 @@ slot (which must later be released with 'release-build-slot'), or #f and #f."
(define (assert-node-has-guix node name) (define (assert-node-has-guix node name)
"Bail out if NODE lacks the (guix) module, or if its daemon is not running." "Bail out if NODE lacks the (guix) module, or if its daemon is not running."
(catch 'node-repl-error
(lambda ()
(match (node-eval node
'(begin
(use-modules (guix))
(and add-text-to-store 'alright)))
('alright #t)
(_ (report-module-error name))))
(lambda (key . args)
(report-module-error name)))
(catch 'node-repl-error (catch 'node-repl-error
(lambda () (lambda ()
(match (node-eval node (match (node-eval node
@ -563,7 +573,7 @@ slot (which must later be released with 'release-build-slot'), or #f and #f."
(info (G_ "Guix is usable on '~a' (test returned ~s)~%") (info (G_ "Guix is usable on '~a' (test returned ~s)~%")
name str)) name str))
(x (x
(leave (G_ "failed to use Guix module on '~a' (test returned ~s)~%") (leave (G_ "failed to talk to guix-daemon on '~a' (test returned ~s)~%")
name x)))) name x))))
(lambda (key . args) (lambda (key . args)
(leave (G_ "remove evaluation on '~a' failed:~{ ~s~}~%") (leave (G_ "remove evaluation on '~a' failed:~{ ~s~}~%")

View File

@ -41,7 +41,10 @@
send-files send-files
retrieve-files retrieve-files
retrieve-files* retrieve-files*
remote-store-host)) remote-store-host
report-guile-error
report-module-error))
;;; Commentary: ;;; Commentary:
;;; ;;;
@ -365,21 +368,9 @@ from REMOTE. When RECURSIVE? is true, retrieve the closure of FILES."
(lambda () (lambda ()
(close-port port)))) (close-port port))))
((? eof-object?) ((? eof-object?)
(raise-error (G_ "failed to start Guile on remote host '~A': exit code ~A") (report-guile-error (remote-store-host remote)))
(remote-store-host remote)
(channel-get-exit-status port)
(=> (G_ "Make sure @command{guile} can be found in
@code{$PATH} on the remote host. Run @command{ssh ~A guile --version} to
check.")
(remote-store-host remote))))
(('module-error . _) (('module-error . _)
;; TRANSLATORS: Leave "Guile" untranslated. (report-module-error (remote-store-host remote)))
(raise-error (G_ "Guile modules not found on remote host '~A'")
(remote-store-host remote)
(=> (G_ "Make sure @code{GUILE_LOAD_PATH} includes Guix'
own module directory. Run @command{ssh ~A env | grep GUILE_LOAD_PATH} to
check.")
(remote-store-host remote))))
(('connection-error file code . _) (('connection-error file code . _)
(raise-error (G_ "failed to connect to '~A' on remote host '~A': ~a") (raise-error (G_ "failed to connect to '~A' on remote host '~A': ~a")
file (remote-store-host remote) (strerror code))) file (remote-store-host remote) (strerror code)))
@ -406,4 +397,25 @@ LOCAL. When RECURSIVE? is true, retrieve the closure of FILES."
#:import (lambda (port) #:import (lambda (port)
(import-paths local port)))) (import-paths local port))))
;;;
;;; Error reporting.
;;;
(define (report-guile-error host)
(raise-error (G_ "failed to start Guile on remote host '~A'") host
(=> (G_ "Make sure @command{guile} can be found in
@code{$PATH} on the remote host. Run @command{ssh ~A guile --version} to
check.")
host)))
(define (report-module-error host)
"Report an error about missing Guix modules on HOST."
;; TRANSLATORS: Leave "Guile" untranslated.
(raise-error (G_ "Guile modules not found on remote host '~A'") host
(=> (G_ "Make sure @code{GUILE_LOAD_PATH} includes Guix'
own module directory. Run @command{ssh ~A env | grep GUILE_LOAD_PATH} to
check.")
host)))
;;; ssh.scm ends here ;;; ssh.scm ends here