From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 18 05:51:16 2020 Received: (at submit) by debbugs.gnu.org; 18 Dec 2020 10:51:16 +0000 Received: from localhost ([127.0.0.1]:37809 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kqDLv-0007c6-QH for submit@debbugs.gnu.org; Fri, 18 Dec 2020 05:51:16 -0500 Received: from lists.gnu.org ([209.51.188.17]:40510) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kqDLt-0007by-Bl for submit@debbugs.gnu.org; Fri, 18 Dec 2020 05:51:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqDLr-0006M3-Gt for guix-patches@gnu.org; Fri, 18 Dec 2020 05:51:12 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:49197) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqDLq-0007o5-6z; Fri, 18 Dec 2020 05:51:10 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=52132 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kqDLo-0004N9-HC; Fri, 18 Dec 2020 05:51:10 -0500 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: guix-patches@gnu.org Subject: [PATCH] ssh: Use 'guix repl' instead of 'guile'. Date: Fri, 18 Dec 2020 11:51:01 +0100 Message-Id: <20201218105101.27869-1-ludo@gnu.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) This simplifies setup of build machines: no need to install Guile in addition to Guix, no need to set 'GUILE_LOAD_PATH' & co., leading to fewer failure modes. * guix/ssh.scm (remote-run): New procedure. (remote-daemon-channel): Use it instead of 'open-remote-pipe*'. (store-import-channel)[import]: Remove check for module availability. Add call to 'primitive-exit'. Use 'remote-run' instead of 'open-remote-pipe'. (store-export-channel)[export]: Remove check for module availability. Add calls to 'primitive-exit'. Use 'remote-run' instead of 'open-remote-pipe'. (handle-import/export-channel-error): Remove 'module-error' clause. (report-module-error): Remove. * guix/scripts/offload.scm (assert-node-has-guix): Replace call to 'report-module-error' by 'leave'. * doc/guix.texi (Daemon Offload Setup): Remove mention of Guile. --- doc/guix.texi | 2 +- guix/scripts/offload.scm | 3 +- guix/ssh.scm | 91 +++++++++++++++++++++------------------- 3 files changed, 51 insertions(+), 45 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 392baf5910..7ae05b47a9 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -1296,7 +1296,7 @@ master node: @end example This will attempt to connect to each of the build machines specified in -@file{/etc/guix/machines.scm}, make sure Guile and the Guix modules are +@file{/etc/guix/machines.scm}, make sure Guix is available on each machine, attempt to export to the machine and import from it, and report any error in the process. diff --git a/guix/scripts/offload.scm b/guix/scripts/offload.scm index 58ee53e85c..835078cb97 100644 --- a/guix/scripts/offload.scm +++ b/guix/scripts/offload.scm @@ -634,7 +634,8 @@ daemon is not running." (and add-text-to-store 'alright)) node) ('alright #t) - (_ (report-module-error name))) + (_ (leave (G_ "(guix) module not usable on remote host '~a'") + name))) (match (inferior-eval '(begin (use-modules (guix)) diff --git a/guix/ssh.scm b/guix/ssh.scm index e41bffca65..457d1890f9 100644 --- a/guix/ssh.scm +++ b/guix/ssh.scm @@ -54,8 +54,7 @@ retrieve-files* remote-store-host - report-guile-error - report-module-error)) + report-guile-error)) ;;; Commentary: ;;; @@ -206,6 +205,40 @@ REPL." ;; .) (close-inferior inferior))))) +(define (remote-run exp session) + "Run EXP in a new process in SESSION and return a remote pipe. + +Unlike 'inferior-remote-eval', this is used for side effects and may +communicate over stdout/stdin as it sees fit. EXP is typically a loop that +processes data from stdin and/or sends data to stdout. The assumption is that +EXP never returns or calls 'primitive-exit' when it's done." + (define pipe + (open-remote-pipe* session OPEN_BOTH + "guix" "repl" "-t" "machine")) + + (match (read pipe) + (('repl-version _ ...) + #t) + ((? eof-object?) + (close-port pipe) + (raise (formatted-message + (G_ "failed to start 'guix repl' on '~a'") + (session-get session 'host))))) + + ;; Disable buffering so 'guix repl' does not read more than what's really + ;; sent to itself. + (write '(setvbuf (current-input-port) 'none) pipe) + (force-output pipe) + + ;; Read the reply and subsequent newline. + (read pipe) (get-u8 pipe) + + (write exp pipe) + (force-output pipe) + + ;; From now on, we stop following the inferior protocol. + pipe) + (define* (remote-daemon-channel session #:optional (socket-name @@ -261,11 +294,7 @@ REPL." (_ (primitive-exit 1))))))) - (open-remote-pipe* session OPEN_BOTH - ;; Sort-of shell-quote REDIRECT. - "guile" "-c" - (object->string - (object->string redirect)))) + (remote-run redirect session)) (define* (connect-to-remote-daemon session #:optional @@ -288,11 +317,6 @@ can be written." ;; consumed. (define import `(begin - (eval-when (load expand eval) - (unless (resolve-module '(guix) #:ensure #f) - (write `(module-error)) - (exit 7))) - (use-modules (guix) (srfi srfi-34) (rnrs io ports) (rnrs bytevectors)) @@ -322,13 +346,10 @@ can be written." (import-paths store (current-input-port)) '(success)))) (lambda args - (cons 'error args)))))) + (cons 'error args)))) + (primitive-exit 0))) - (open-remote-pipe session - (string-join - `("guile" "-c" - ,(object->string (object->string import)))) - OPEN_BOTH)) + (remote-run import session)) (define* (store-export-channel session files #:key recursive?) @@ -338,22 +359,20 @@ be read. When RECURSIVE? is true, the closure of FILES is exported." ;; remote store. (define export `(begin - (eval-when (load expand eval) - (unless (resolve-module '(guix) #:ensure #f) - (write `(module-error)) - (exit 7))) - (use-modules (guix) (srfi srfi-1) (srfi srfi-26) (srfi srfi-34)) (guard (c ((nix-connection-error? c) (write `(connection-error ,(nix-connection-error-file c) - ,(nix-connection-error-code c)))) + ,(nix-connection-error-code c))) + (primitive-exit 1)) ((nix-protocol-error? c) (write `(protocol-error ,(nix-protocol-error-status c) - ,(nix-protocol-error-message c)))) + ,(nix-protocol-error-message c))) + (primitive-exit 2)) (else - (write `(exception)))) + (write `(exception)) + (primitive-exit 3))) (with-store store (let* ((files ',files) (invalid (remove (cut valid-path? store <>) @@ -371,13 +390,10 @@ be read. When RECURSIVE? is true, the closure of FILES is exported." (setvbuf (current-output-port) 'none) (export-paths store files (current-output-port) - #:recursive? ,recursive?)))))) + #:recursive? ,recursive?) + (primitive-exit 0)))))) - (open-remote-input-pipe session - (string-join - `("guile" "-c" - ,(object->string - (object->string export)))))) + (remote-run export session)) (define (remote-system session) "Return the system type as expected by Nix, usually ARCHITECTURE-KERNEL, of @@ -563,8 +579,6 @@ REMOTE." (match sexp ((? eof-object?) (report-guile-error (remote-store-host remote))) - (('module-error . _) - (report-module-error (remote-store-host remote))) (('connection-error file code . _) (raise-error (G_ "failed to connect to '~A' on remote host '~A': ~a") file (remote-store-host remote) (strerror code))) @@ -626,15 +640,6 @@ LOCAL. When RECURSIVE? is true, retrieve the closure of FILES." 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))) - (define (report-inferior-exception exception host) "Report EXCEPTION, an &inferior-exception that occurred on HOST." (raise-error (G_ "exception occurred on remote host '~A': ~s") -- 2.29.2 From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 23 10:06:57 2020 Received: (at 45312) by debbugs.gnu.org; 23 Dec 2020 15:06:57 +0000 Received: from localhost ([127.0.0.1]:53812 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ks5j7-0002rh-LT for submit@debbugs.gnu.org; Wed, 23 Dec 2020 10:06:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51944) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ks5j6-0002rR-7s for 45312@debbugs.gnu.org; Wed, 23 Dec 2020 10:06:56 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:51357) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ks5j1-0001g4-4m for 45312@debbugs.gnu.org; Wed, 23 Dec 2020 10:06:51 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=46060 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ks5iy-0005VJ-MR for 45312@debbugs.gnu.org; Wed, 23 Dec 2020 10:06:50 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: 45312@debbugs.gnu.org Subject: Re: [bug#45312] [PATCH] ssh: Use 'guix repl' instead of 'guile'. References: <20201218105101.27869-1-ludo@gnu.org> Date: Wed, 23 Dec 2020 16:06:47 +0100 In-Reply-To: <20201218105101.27869-1-ludo@gnu.org> ("Ludovic =?utf-8?Q?Cou?= =?utf-8?Q?rt=C3=A8s=22's?= message of "Fri, 18 Dec 2020 11:51:01 +0100") Message-ID: <87k0t8wohk.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 45312 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Ludovic Court=C3=A8s skribis: > This simplifies setup of build machines: no need to install Guile in > addition to Guix, no need to set 'GUILE_LOAD_PATH' & co., leading to > fewer failure modes. > > * guix/ssh.scm (remote-run): New procedure. > (remote-daemon-channel): Use it instead of 'open-remote-pipe*'. > (store-import-channel)[import]: Remove check for module availability. > Add call to 'primitive-exit'. > Use 'remote-run' instead of 'open-remote-pipe'. > (store-export-channel)[export]: Remove check for module availability. > Add calls to 'primitive-exit'. > Use 'remote-run' instead of 'open-remote-pipe'. > (handle-import/export-channel-error): Remove 'module-error' clause. > (report-module-error): Remove. > * guix/scripts/offload.scm (assert-node-has-guix): Replace call to > 'report-module-error' by 'leave'. > * doc/guix.texi (Daemon Offload Setup): Remove mention of Guile. > --- > doc/guix.texi | 2 +- > guix/scripts/offload.scm | 3 +- > guix/ssh.scm | 91 +++++++++++++++++++++------------------- > 3 files changed, 51 insertions(+), 45 deletions(-) Pushed as 7624ebbae33cf49dded5e9032ed426781c9554f6! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 23 10:07:08 2020 Received: (at control) by debbugs.gnu.org; 23 Dec 2020 15:07:08 +0000 Received: from localhost ([127.0.0.1]:53819 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ks5jH-0002sx-UP for submit@debbugs.gnu.org; Wed, 23 Dec 2020 10:07:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51976) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ks5jF-0002rt-Vs for control@debbugs.gnu.org; Wed, 23 Dec 2020 10:07:06 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:51360) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ks5jA-0001k0-Sn for control@debbugs.gnu.org; Wed, 23 Dec 2020 10:07:00 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=46064 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ks5j7-0005VT-FW for control@debbugs.gnu.org; Wed, 23 Dec 2020 10:06:58 -0500 Date: Wed, 23 Dec 2020 16:06:56 +0100 Message-Id: <87im8swohb.fsf@gnu.org> To: control@debbugs.gnu.org From: =?utf-8?Q?Ludovic_Court=C3=A8s?= Subject: control message for bug #45312 MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) tags 45312 fixed close 45312 quit From unknown Thu Aug 14 22:22:21 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 21 Jan 2021 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator