unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Carlo Zancanaro <carlo@zancanaro.id.au>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 22039@debbugs.gnu.org
Subject: bug#22039: [PATCH] 'guix system reconfigure' must start/restart/stop services
Date: Sat, 01 Sep 2018 22:33:14 +1000	[thread overview]
Message-ID: <87tvn9z9bp.fsf@zancanaro.id.au> (raw)
In-Reply-To: <87va7pza4p.fsf@zancanaro.id.au>


[-- Attachment #1.1: Type: text/plain, Size: 149 bytes --]

On Sat, Sep 01 2018, Carlo Zancanaro wrote:
> I'll send through an updated patch once I've cleaned it up a 
> bit, [ ... ]

Updated patch attached.


[-- Attachment #1.2: 0001-gnu-services-Load-all-services-on-reconfigure-not-ju.patch --]
[-- Type: text/x-patch, Size: 7125 bytes --]

From 47647b767930d16ab5a3b855993daf6ddf98f230 Mon Sep 17 00:00:00 2001
From: Carlo Zancanaro <carlo@zancanaro.id.au>
Date: Sun, 26 Aug 2018 21:54:14 +1000
Subject: [PATCH] gnu: services: Load all services on reconfigure, not just
 stopped ones

* doc/guix.texi (Invoking guix system): Document the new behaviour.
* gnu/services/shepherd.scm (shepherd-service-upgrade): Return a list of
  services that need to be restarted to complete their upgrade.
* guix/scripts/system.scm (call-with-service-upgrade-info): Rename an internal
  variable to reflect the change to shepherd-service-upgrade.
  (upgrade-shepherd-services): Print the names of services that need to be
  restarted in order to be upgraded.
---
 doc/guix.texi             |  8 ++++----
 gnu/services/shepherd.scm | 23 ++++++++---------------
 guix/scripts/system.scm   | 20 ++++++++++++--------
 3 files changed, 24 insertions(+), 27 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index d2d278df4..421762122 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -33,7 +33,7 @@ Copyright @copyright{} 2016 Alex ter Weele@*
 Copyright @copyright{} 2017, 2018 Clément Lassieur@*
 Copyright @copyright{} 2017 Mathieu Othacehe@*
 Copyright @copyright{} 2017 Federico Beffa@*
-Copyright @copyright{} 2017 Carlo Zancanaro@*
+Copyright @copyright{} 2017, 2018 Carlo Zancanaro@*
 Copyright @copyright{} 2017 Thomas Danckaert@*
 Copyright @copyright{} 2017 humanitiesNerd@*
 Copyright @copyright{} 2017 Christopher Allan Webber@*
@@ -21143,9 +21143,9 @@ systems already running GuixSD.}.
 This effects all the configuration specified in @var{file}: user
 accounts, system services, global package list, setuid programs, etc.
 The command starts system services specified in @var{file} that are not
-currently running; if a service is currently running, it does not
-attempt to upgrade it since this would not be possible without stopping it
-first.
+currently running; if a service is currently running this command will
+arrange for it to be upgraded the next time it is stopped (eg. by
+@code{herd stop X} or @code{herd restart X}).
 
 This command creates a new generation whose number is one greater than
 the current generation (as reported by @command{guix system
diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm
index 4cd224984..4c7e72049 100644
--- a/gnu/services/shepherd.scm
+++ b/gnu/services/shepherd.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2013, 2014, 2015, 2016, 2018 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
+;;; Copyright © 2018 Carlo Zancanaro <carlo@zancanaro.id.au>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -329,7 +330,7 @@ symbols provided/required by a service."
 (define (shepherd-service-upgrade live target)
   "Return two values: the subset of LIVE (a list of <live-service>) that needs
 to be unloaded, and the subset of TARGET (a list of <shepherd-service>) that
-needs to be loaded."
+need to be restarted to complete their upgrade."
   (define (essential? service)
     (memq (first (live-service-provision service))
           '(root shepherd)))
@@ -346,12 +347,6 @@ needs to be loaded."
     (and=> (lookup-live (shepherd-service-canonical-name service))
            live-service-running))
 
-  (define (stopped service)
-    (match (lookup-live (shepherd-service-canonical-name service))
-      (#f #f)
-      (service (and (not (live-service-running service))
-                    service))))
-
   (define live-service-dependents
     (shepherd-service-back-edges live
                                  #:provision live-service-provision
@@ -362,16 +357,14 @@ needs to be loaded."
       (#f (every obsolete? (live-service-dependents service)))
       (_  #f)))
 
-  (define to-load
-    ;; Only load services that are either new or currently stopped.
-    (remove running? target))
+  (define to-restart
+    ;; Restart services that are currently running.
+    (filter running? target))
 
   (define to-unload
-    ;; Unload services that are (1) no longer required, or (2) are in TO-LOAD.
-    (remove essential?
-            (append (filter obsolete? live)
-                    (filter-map stopped to-load))))
+    ;; Unload services that are no longer required.
+    (remove essential? (filter obsolete? live)))
 
-  (values to-unload to-load))
+  (values to-unload to-restart))
 
 ;;; shepherd.scm ends here
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 69bd05b51..41a348a5b 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -310,9 +310,9 @@ names of services to load (upgrade), and the list of names of services to
 unload."
   (match (current-services)
     ((services ...)
-     (let-values (((to-unload to-load)
+     (let-values (((to-unload to-restart)
                    (shepherd-service-upgrade services new-services)))
-       (mproc to-load
+       (mproc to-restart
               (map (compose first live-service-provision)
                    to-unload))))
     (#f
@@ -335,21 +335,25 @@ bring the system down."
   ;; Arrange to simply emit a warning if the service upgrade fails.
   (with-shepherd-error-handling
    (call-with-service-upgrade-info new-services
-     (lambda (to-load to-unload)
+     (lambda (to-restart to-unload)
         (for-each (lambda (unload)
                     (info (G_ "unloading service '~a'...~%") unload)
                     (unload-service unload))
                   to-unload)
 
         (with-monad %store-monad
-          (munless (null? to-load)
-            (let ((to-load-names  (map shepherd-service-canonical-name to-load))
-                  (to-start       (filter shepherd-service-auto-start? to-load)))
-              (info (G_ "loading new services:~{ ~a~}...~%") to-load-names)
+          (munless (null? new-services)
+            (let ((new-service-names  (map shepherd-service-canonical-name new-services))
+                  (to-restart-names   (map shepherd-service-canonical-name to-restart))
+                  (to-start           (filter shepherd-service-auto-start? new-services)))
+              (info (G_ "loading new services:~{ ~a~}...~%") new-service-names)
+              (unless (null? to-restart-names)
+                (format #t (G_ "To complete the upgrade, restart the following services:~%"))
+                (for-each (cut format #t "~4t~a~%" <>) to-restart-names))
               (mlet %store-monad ((files (mapm %store-monad
                                                (compose lower-object
                                                         shepherd-service-file)
-                                               to-load)))
+                                               new-services)))
                 ;; Here we assume that FILES are exactly those that were computed
                 ;; as part of the derivation that built OS, which is normally the
                 ;; case.
-- 
2.18.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2018-09-01 12:34 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-28 16:35 bug#22039: 'guix system reconfigure' must start/restart/stop services Ludovic Courtès
2016-01-08 10:04 ` Ludovic Courtès
2016-02-03 21:32 ` Ludovic Courtès
2016-02-03 21:34   ` Thompson, David
2018-01-16 11:17 ` bug#22039: ‘guix system reconfigure’ does not always load new services Ludovic Courtès
2018-08-26 12:15 ` bug#22039: [PATCH] 'guix system reconfigure' must start/restart/stop services Carlo Zancanaro
2018-09-01 10:49   ` Ludovic Courtès
2018-09-01 12:15     ` Carlo Zancanaro
2018-09-01 12:33       ` Carlo Zancanaro [this message]
2018-09-01 17:12       ` Ludovic Courtès
2018-09-02  3:43         ` Carlo Zancanaro
2018-09-02 20:39           ` Ludovic Courtès
2018-09-19 15:47           ` Ludovic Courtès
2018-09-19 20:56             ` Carlo Zancanaro
2018-09-20  9:47               ` Ludovic Courtès
2018-09-20 10:24                 ` Carlo Zancanaro
2018-09-20 11:08                   ` Ludovic Courtès
2018-09-20 11:50                     ` Carlo Zancanaro
2018-09-21 11:58                       ` Ludovic Courtès
2018-09-23  8:26                         ` Efraim Flashner
2018-09-23 19:53                           ` Ludovic Courtès
2018-09-23 23:06                         ` Carlo Zancanaro
2018-09-24  8:58                           ` Ludovic Courtès
2018-09-24 10:18                             ` Carlo Zancanaro
2018-09-26 21:46                               ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tvn9z9bp.fsf@zancanaro.id.au \
    --to=carlo@zancanaro.id.au \
    --cc=22039@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).