From patchwork Fri Jan 26 10:59:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herman Rimm X-Patchwork-Id: 59418 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9CB2D27BBEA; Fri, 26 Jan 2024 11:07:19 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 0892527BBE9 for ; Fri, 26 Jan 2024 11:07:18 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rTK34-0002p9-BS; Fri, 26 Jan 2024 06:07:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rTK32-0002om-0F for guix-patches@gnu.org; Fri, 26 Jan 2024 06:07:00 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rTK30-0002BN-VR; Fri, 26 Jan 2024 06:06:58 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rTK33-0002Sj-VX; Fri, 26 Jan 2024 06:07:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68733] [PATCH] machine: ssh: Add 'graft?' field. Resent-From: Herman Rimm Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Fri, 26 Jan 2024 11:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 68733 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68733@debbugs.gnu.org Cc: Herman Rimm , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by submit@debbugs.gnu.org id=B.17062671779411 (code B ref -1); Fri, 26 Jan 2024 11:07:01 +0000 Received: (at submit) by debbugs.gnu.org; 26 Jan 2024 11:06:17 +0000 Received: from localhost ([127.0.0.1]:50547 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rTK2K-0002Rj-S6 for submit@debbugs.gnu.org; Fri, 26 Jan 2024 06:06:17 -0500 Received: from lists.gnu.org ([2001:470:142::17]:59960) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rTK2J-0002RN-6o for submit@debbugs.gnu.org; Fri, 26 Jan 2024 06:06:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rTK25-0002Hc-6H for guix-patches@gnu.org; Fri, 26 Jan 2024 06:06:01 -0500 Received: from 81-205-150-117.fixed.kpn.net ([81.205.150.117] helo=email.rimm.ee) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1rTK23-0001ro-2F for guix-patches@gnu.org; Fri, 26 Jan 2024 06:06:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rimm.ee; s=herman; t=1706267152; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ToopVGtORmAJ08CdKvyY7oJ3C1PGWe32Z0YnbDIHQTA=; b=Kfm5KPVLH4ZPe8+Wt0TVOwc4kqJu787XWunA6N96vbSU7MokUPmc6QpY4OgkmD3tfvfXtt jPvLpnF3bdsHBUT09odnuVL4O3KKpKEGysuWJiFWzz/eL5aM5npHJPZIlnlZ24FeZMy6lW bMDBmXUFJhpg3dm+AgVyRrZ8EK07Cn4Ms1ndNByt2wpkbXtc29XIAQJHqg/RESxKQMtoXO RWXKWVnbP0nWzgJSbVTyZgYc4GkAOGmkjeKoA8LNpAaSNHpmN2Nx8okeWAqehNsWRfIKL7 1A9Z6JyI4E3GfAf53lCKI4TFwrkjQwBWYPdTEt9RXGil0FWubCd+PtBXNjHZWw== Received: by 81-205-150-117.fixed.kpn.net (OpenSMTPD) with ESMTPSA id 70a8c77b (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO); Fri, 26 Jan 2024 11:05:51 +0000 (UTC) Date: Fri, 26 Jan 2024 11:59:30 +0100 Message-ID: <1eb737122611aa921fb8ec0257de0cb5aad5022e.1706266770.git.herman@rimm.ee> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Received-SPF: pass client-ip=81.205.150.117; envelope-from=herman@rimm.ee; helo=email.rimm.ee X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_PBL=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, TVD_RCVD_IP=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Herman Rimm X-ACL-Warn: , Herman Rimm via Guix-patches X-Patchwork-Original-From: Herman Rimm via Guix-patches via From: Herman Rimm Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/machine/ssh.scm ()[graft?]: New field. * gnu/scripts/deploy.scm (deploy-machine*): Reparameterize %graft?. * doc/guix.texi (Invoking guix deploy): Document it. Change-Id: Ide83bb465c9f30165f4ddc64e48c1b89484e3e69 --- Hi, This patch allows disabling grafts per machine by way of a new graft? field for machine-ssh-configuration. I don't know what happens when a digital-ocean-configuration is used. But that won't matter if %graft? can be parameterized in (deploy-managed-host machine) in /gnu/machine/ ssh.scm. However if %graft? is parameterized alongside %current-system, it does not affect grafting. Where should %graft? be parameterized? Cheers, Herman doc/guix.texi | 5 ++++ gnu/machine/ssh.scm | 10 ++++--- guix/scripts/deploy.scm | 58 ++++++++++++++++++++++------------------- 3 files changed, 42 insertions(+), 31 deletions(-) base-commit: cdf1d7dded027019f0ebbd5d6f0147b13dfdd28d diff --git a/doc/guix.texi b/doc/guix.texi index db0c751ded..2e316ae709 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -124,6 +124,7 @@ Copyright @copyright{} 2023 Saku Laesvuori@* Copyright @copyright{} 2023 Graham James Addis@* Copyright @copyright{} 2023 Tomas Volf@* +Copyright @copyright{} 2024 Herman Rimm@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -42359,6 +42360,10 @@ Invoking guix deploy @item @code{authorize?} (default: @code{#t}) If true, the coordinator's signing key will be added to the remote's ACL keyring. +@item @code{graft?} (default: @code{#t}) +If false, system derivations will be built without applying any grafts onto +packages. Grafting should be disabled for deployment to machines with a +differing architecture. @item @code{port} (default: @code{22}) @item @code{user} (default: @code{"root"}) @item @code{identity} (default: @code{#f}) diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm index b5984dc732..881576ff74 100644 --- a/gnu/machine/ssh.scm +++ b/gnu/machine/ssh.scm @@ -63,6 +63,7 @@ (define-module (gnu machine ssh) machine-ssh-configuration-build-locally? machine-ssh-configuration-authorize? machine-ssh-configuration-allow-downgrades? + machine-ssh-configuration-graft? machine-ssh-configuration-port machine-ssh-configuration-user machine-ssh-configuration-host-key @@ -95,6 +96,8 @@ (define-record-type* machine-ssh-configuration (default #t)) (allow-downgrades? machine-ssh-configuration-allow-downgrades? ; boolean (default #f)) + (graft? machine-ssh-configuration-graft? ; boolean + (default #t)) (safety-checks? machine-ssh-configuration-safety-checks? ;boolean (default #t)) (port machine-ssh-configuration-port ; integer @@ -489,12 +492,10 @@ (define (deploy-managed-host machine) "Internal implementation of 'deploy-machine' for MACHINE instances with an environment type of 'managed-host." (define config (machine-configuration machine)) - (define host (machine-ssh-configuration-host-name config)) (define system (machine-ssh-configuration-system config)) (maybe-raise-unsupported-configuration-error machine) - (when (machine-ssh-configuration-authorize? - (machine-configuration machine)) + (when (machine-ssh-configuration-authorize? config) (unless (file-exists? %public-key-file) (raise (formatted-message (G_ "no signing key '~a'. \ Have you run 'guix archive --generate-key'?") @@ -512,7 +513,8 @@ (define (deploy-managed-host machine) ;; %BASE-INITRD-MODULES, gets to see the right value. (parameterize ((%current-system system) (%current-target-system #f)) - (let* ((os (machine-operating-system machine)) + (let* ((host (machine-ssh-configuration-host-name config)) + (os (machine-operating-system machine)) (eval (cut machine-remote-eval machine <>)) (menu-entries (map boot-parameters->menu-entry boot-parameters)) (bootloader-configuration (operating-system-bootloader os)) diff --git a/guix/scripts/deploy.scm b/guix/scripts/deploy.scm index 4b1a603049..8ffc45e8c3 100644 --- a/guix/scripts/deploy.scm +++ b/guix/scripts/deploy.scm @@ -20,6 +20,7 @@ (define-module (guix scripts deploy) #:use-module (gnu machine) + #:use-module (gnu machine ssh) #:use-module (guix discovery) #:use-module (guix scripts) #:use-module (guix scripts build) @@ -138,35 +139,38 @@ (define (deploy-machine* store machine) (info (G_ "deploying to ~a...~%") (machine-display-name machine)) - (guard* (c - ;; On Guile 3.0, exceptions such as 'unbound-variable' are compound - ;; and include a '&message'. However, that message only contains - ;; the format string. Thus, special-case it here to avoid - ;; displaying a bare format string. - (((exception-predicate &exception-with-kind-and-args) c) - (raise c)) + (define config (machine-configuration machine)) + (define graft? (machine-ssh-configuration-graft? config)) + (parameterize ((%graft? (and (%graft?) graft?))) + (guard* (c + ;; On Guile 3.0, exceptions such as 'unbound-variable' are compound + ;; and include a '&message'. However, that message only contains + ;; the format string. Thus, special-case it here to avoid + ;; displaying a bare format string. + (((exception-predicate &exception-with-kind-and-args) c) + (raise c)) - ((message-condition? c) - (leave (G_ "failed to deploy ~a: ~a~%") - (machine-display-name machine) - (condition-message c))) - ((formatted-message? c) - (leave (G_ "failed to deploy ~a: ~a~%") - (machine-display-name machine) - (apply format #f - (gettext (formatted-message-string c) - %gettext-domain) - (formatted-message-arguments c)))) - ((deploy-error? c) - (when (deploy-error-should-roll-back c) - (info (G_ "rolling back ~a...~%") - (machine-display-name machine)) - (run-with-store store (roll-back-machine machine))) - (apply throw (deploy-error-captured-args c)))) - (run-with-store store (deploy-machine machine)) + ((message-condition? c) + (leave (G_ "failed to deploy ~a: ~a~%") + (machine-display-name machine) + (condition-message c))) + ((formatted-message? c) + (leave (G_ "failed to deploy ~a: ~a~%") + (machine-display-name machine) + (apply format #f + (gettext (formatted-message-string c) + %gettext-domain) + (formatted-message-arguments c)))) + ((deploy-error? c) + (when (deploy-error-should-roll-back c) + (info (G_ "rolling back ~a...~%") + (machine-display-name machine)) + (run-with-store store (roll-back-machine machine))) + (apply throw (deploy-error-captured-args c)))) + (run-with-store store (deploy-machine machine)) - (info (G_ "successfully deployed ~a~%") - (machine-display-name machine)))) + (info (G_ "successfully deployed ~a~%") + (machine-display-name machine))))) (define (invoke-command store machine command) "Invoke COMMAND, a list of strings, on MACHINE. Display its output (if any)