From patchwork Sun Feb 23 14:47:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 39002 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 EF3BB27BBEA; Sun, 23 Feb 2025 14:49:16 +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=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, 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 6CA1827BBE2 for ; Sun, 23 Feb 2025 14:49:16 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tmDI7-0006Eq-RA; Sun, 23 Feb 2025 09:49:13 -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 1tmDI1-0006Di-LC for guix-patches@gnu.org; Sun, 23 Feb 2025 09:49:05 -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 1tmDI1-0007AY-B6; Sun, 23 Feb 2025 09:49:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=n++lYMMtAHP353rU9/L38zsmXIkqLZXPKEBph3iYvj0=; b=apATGmAZbKTfRvlHAK2EVdFt+ZUSIg5P+flbKF9weVHuexxXDeDyk1JC57JxcSGQzZFZCv37BwqL+v9kywEbU8ySXUwMpRlsSyKY/WmPpuELkyZkH3Ijm5aQzKtLS5kQ3d96LGXMXIpDym47ETe/sNGnB76LnETSnM7eFrNkk+moJLapnu+e49jDoZ8hLUUYgBcT9pO6HP6+P1I9PTNVUTDD1VU576IXYQLOtGKR2t0ksQFoQ8pVwKLP3hup4j1nSgB1b8vJgLCS8eiN90z627m4Q9hlRAmoEfTsPpV5m2C2CqQEKzIqR1jK2tmZMlrGScmUKbEy3kKOLXkYPaRVVA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tmDHz-0004zL-L6; Sun, 23 Feb 2025 09:49:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#76502] [PATCH] services: =?utf-8?b?4oCYc2hlcGhlcmQtc2Vydmlj?= =?utf-8?b?ZS11cGdyYWRl4oCZ?= handles canonical name changes. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Sun, 23 Feb 2025 14:49:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 76502 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 76502@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Tomas Volf <~@wolfsden.cz>, Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , 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 , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by submit@debbugs.gnu.org id=B.174032209119076 (code B ref -1); Sun, 23 Feb 2025 14:49:03 +0000 Received: (at submit) by debbugs.gnu.org; 23 Feb 2025 14:48:11 +0000 Received: from localhost ([127.0.0.1]:60088 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tmDH8-0004xc-WA for submit@debbugs.gnu.org; Sun, 23 Feb 2025 09:48:11 -0500 Received: from lists.gnu.org ([2001:470:142::17]:47762) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tmDH5-0004wv-K4 for submit@debbugs.gnu.org; Sun, 23 Feb 2025 09:48:08 -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 1tmDGx-0005d0-7n for guix-patches@gnu.org; Sun, 23 Feb 2025 09:47:59 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tmDGv-00075y-MO; Sun, 23 Feb 2025 09:47:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=n++lYMMtAHP353rU9/L38zsmXIkqLZXPKEBph3iYvj0=; b=IgV12vgqgJe/RZ Ci7yTlVncJXLZxwkvN2EKFqXgUzU0nvd10yiVLJfPGhGFFQGMgxJc1P/jT+a/LGH1K8NaoKVQeIsq sF5PFu7CFjRvbzidPrnVR3Bibs+XjNfeXzmb9vpw/W7Iim5RYxNSmY2IX2O/4edKzK9+bsRz0bWmB lZV0DSbVjryO67PFtCs5VoJB22PPpPhBlmJTj56y1b+n3QcuXiQQSQTjd/xKu18jWcFZf67IqiP8H IqJtKIOGJ3iw5OuexBz9aFnfjOW7gXYBXVu3xsKVG+ibzpYjOlG1yGXW7lFa+Y5TTrC98LN8YL0Vh bVMx+9zt2rPky4/U2o9w==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Sun, 23 Feb 2025 15:47:41 +0100 Message-ID: <220207cd49aa16783ecb3c4293e1e75dedeae8fa.1740321954.git.ludo@gnu.org> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 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: , 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 Partly fixes . Fixes a bug whereby a service whose canonical name has changed would not be restarted—e.g., if '(syslogd) has a replacement providing '(system-log syslogd). * gnu/services/shepherd.scm (shepherd-service-upgrade)[running?]: Remove. [to-restart]: Change to a subset of LIVE. Look up all the names of each element of TARGET. * guix/scripts/system/reconfigure.scm (upgrade-shepherd-services): TO-RESTART is now a list of ; adjust accordingly. * tests/services.scm ("shepherd-service-upgrade: one unchanged, one upgraded, one new"): ("shepherd-service-upgrade: service depended on is not unloaded"): ("shepherd-service-upgrade: obsolete services that depend on each other"): ("shepherd-service-upgrade: transient service"): Adjust accordingly. ("shepherd-service-upgrade: service has new canonical name"): New test. Reported-by: Tomas Volf <~@wolfsden.cz> Change-Id: I7cec495b4e824da5fad5518f039607cf92f935d9 Reviewed-by: Tomas Volf <~@wolfsden.cz> --- gnu/services/shepherd.scm | 18 ++++++++++-------- guix/scripts/system/reconfigure.scm | 2 +- tests/services.scm | 27 ++++++++++++++++++++++----- 3 files changed, 33 insertions(+), 14 deletions(-) Hello! This should fix the ‘guix deploy’ warning Tomas reported in when upgrading to the Shepherd’s ‘system-log’. In short, confusion was cause by the fact that '(syslogd) was to be replaced by '(system-log syslogd), and the canonical name of the latter is ‘system-log’, not ‘syslogd’. Ludo’. base-commit: 90aa90eb05429553402e0b5225d23f84742a9286 diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm index cfbb3f1e30a..65c49b9c59a 100644 --- a/gnu/services/shepherd.scm +++ b/gnu/services/shepherd.scm @@ -517,8 +517,8 @@ (define* (shepherd-service-back-edges services (define (shepherd-service-upgrade live target) "Return two values: the subset of LIVE (a list of ) that needs -to be unloaded, and the subset of TARGET (a list of ) that -need to be restarted to complete their upgrade." +to be unloaded, and the subset of LIVE that needs to be restarted to complete +their upgrade." (define (essential? service) (memq (first (live-service-provision service)) '(root shepherd))) @@ -531,10 +531,6 @@ (define (shepherd-service-upgrade live target) (shepherd-service-lookup-procedure live live-service-provision)) - (define (running? service) - (and=> (lookup-live (shepherd-service-canonical-name service)) - live-service-running)) - (define live-service-dependents (shepherd-service-back-edges live #:provision live-service-provision @@ -546,8 +542,14 @@ (define (shepherd-service-upgrade live target) (_ #f))) (define to-restart - ;; Restart services that are currently running. - (filter running? target)) + ;; Restart services that appear in TARGET and are currently running. + (filter-map (lambda (service) + (and=> (any lookup-live + (shepherd-service-provision service)) + (lambda (live) + (and (live-service-running live) + live)))) + target)) (define to-unload ;; Unload services that are no longer required. Essential services must diff --git a/guix/scripts/system/reconfigure.scm b/guix/scripts/system/reconfigure.scm index d35980590d3..76855b43688 100644 --- a/guix/scripts/system/reconfigure.scm +++ b/guix/scripts/system/reconfigure.scm @@ -214,7 +214,7 @@ (define* (upgrade-shepherd-services eval os) (let* ((to-unload to-restart (shepherd-service-upgrade live-services target-services)) (to-unload (map live-service-canonical-name to-unload)) - (to-restart (map shepherd-service-canonical-name to-restart)) + (to-restart (map live-service-canonical-name to-restart)) (running (map live-service-canonical-name (filter live-service-running live-services))) (to-start (lset-difference eqv? diff --git a/tests/services.scm b/tests/services.scm index 98b584f6c06..993283047f5 100644 --- a/tests/services.scm +++ b/tests/services.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2015-2019, 2022, 2023 Ludovic Courtès +;;; Copyright © 2015-2019, 2022-2023, 2025 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -225,7 +225,7 @@ (define-module (test-services) (start #t))))) (lambda (unload restart) (list (map live-service-provision unload) - (map shepherd-service-provision restart))))) + (map live-service-provision restart))))) (test-equal "shepherd-service-upgrade: service depended on is not unloaded" '(((baz)) ;unload @@ -243,7 +243,7 @@ (define-module (test-services) (start #t))))) (lambda (unload restart) (list (map live-service-provision unload) - (map shepherd-service-provision restart))))) + (map live-service-provision restart))))) (test-equal "shepherd-service-upgrade: obsolete services that depend on each other" '(((foo) (bar) (baz)) ;unload @@ -260,7 +260,7 @@ (define-module (test-services) (start #t))))) (lambda (unload restart) (list (map live-service-provision unload) - (map shepherd-service-provision restart))))) + (map live-service-provision restart))))) (test-equal "shepherd-service-upgrade: transient service" ;; Transient service must not be unloaded: @@ -277,7 +277,24 @@ (define-module (test-services) (start #t))))) (lambda (unload restart) (list (map live-service-provision unload) - (map shepherd-service-provision restart))))) + (map live-service-provision restart))))) + +(test-equal "shepherd-service-upgrade: service has new canonical name" + '(((qux)) ;unload + ((ssh) (foo))) ;restart + (call-with-values + (lambda () + (shepherd-service-upgrade + (list (live-service '(ssh) '() #f 42) ;running + (live-service '(foo) '() #f #t) ;changed canonical name + (live-service '(qux) '() #f #t)) ;obsolete + (list (shepherd-service (provision '(ssh)) + (start #t)) + (shepherd-service (provision '(bar foo)) + (start #t))))) + (lambda (unload restart) + (list (map live-service-provision unload) + (map live-service-provision restart))))) (test-eq "lookup-service-types" system-service-type