services: herd: Adjust to <live-service> changes.

This is a followup to a2c759c8304c461d096ab763568e7f71546ff4e8.

* guix/scripts/system/reconfigure.scm (running-services): Fill in the
'transient?' field of <live-service>.
* 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"): Adjust calls to 'live-service'.
This commit is contained in:
Ludovic Courtès 2022-04-10 01:15:13 +02:00
parent d10cee7865
commit e25eca35ff
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
2 changed files with 15 additions and 13 deletions

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2014-2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016 Alex Kost <alezost@gmail.com> ;;; Copyright © 2016 Alex Kost <alezost@gmail.com>
;;; Copyright © 2016, 2017, 2018 Chris Marusich <cmmarusich@gmail.com> ;;; Copyright © 2016, 2017, 2018 Chris Marusich <cmmarusich@gmail.com>
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
@ -134,6 +134,7 @@ return the <live-service> objects that are currently running on MACHINE."
(map (lambda (service) (map (lambda (service)
(list (live-service-provision service) (list (live-service-provision service)
(live-service-requirement service) (live-service-requirement service)
(live-service-transient service)
(match (live-service-running service) (match (live-service-running service)
(#f #f) (#f #f)
(#t #t) (#t #t)
@ -143,8 +144,9 @@ return the <live-service> objects that are currently running on MACHINE."
(mlet %store-monad ((services (eval exp))) (mlet %store-monad ((services (eval exp)))
(return (map (match-lambda (return (map (match-lambda
((provision requirement running) ((provision requirement transient? running)
(live-service provision requirement running))) (live-service provision requirement
transient? running)))
services)))) services))))
;; XXX: Currently, this does NOT attempt to restart running services. See ;; XXX: Currently, this does NOT attempt to restart running services. See

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2015-2019, 2022 Ludovic Courtès <ludo@gnu.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -212,9 +212,9 @@
;; because it is not currently running. 'baz' is loaded because it's ;; because it is not currently running. 'baz' is loaded because it's
;; a new service. ;; a new service.
(shepherd-service-upgrade (shepherd-service-upgrade
(list (live-service '(foo) '() #t) (list (live-service '(foo) '() #f #t)
(live-service '(bar) '() #f) (live-service '(bar) '() #f #f)
(live-service '(root) '() #t)) ;essential! (live-service '(root) '() #f #t)) ;essential!
(list (shepherd-service (provision '(foo)) (list (shepherd-service (provision '(foo))
(start #t)) (start #t))
(shepherd-service (provision '(bar)) (shepherd-service (provision '(bar))
@ -234,9 +234,9 @@
;; unloaded because 'foo' depends on it. 'foo' gets replaced but it ;; unloaded because 'foo' depends on it. 'foo' gets replaced but it
;; must be restarted manually. ;; must be restarted manually.
(shepherd-service-upgrade (shepherd-service-upgrade
(list (live-service '(foo) '(bar) #t) (list (live-service '(foo) '(bar) #f #t)
(live-service '(bar) '() #t) ;still used! (live-service '(bar) '() #f #t) ;still used!
(live-service '(baz) '() #t)) (live-service '(baz) '() #f #t))
(list (shepherd-service (provision '(foo)) (list (shepherd-service (provision '(foo))
(start #t))))) (start #t)))))
(lambda (unload restart) (lambda (unload restart)
@ -251,9 +251,9 @@
;; 'foo', 'bar', and 'baz' depend on each other, but all of them are ;; 'foo', 'bar', and 'baz' depend on each other, but all of them are
;; obsolete, and thus should be unloaded. ;; obsolete, and thus should be unloaded.
(shepherd-service-upgrade (shepherd-service-upgrade
(list (live-service '(foo) '(bar) #t) ;obsolete (list (live-service '(foo) '(bar) #f #t) ;obsolete
(live-service '(bar) '(baz) #t) ;obsolete (live-service '(bar) '(baz) #f #t) ;obsolete
(live-service '(baz) '() #t)) ;obsolete (live-service '(baz) '() #f #t)) ;obsolete
(list (shepherd-service (provision '(qux)) (list (shepherd-service (provision '(qux))
(start #t))))) (start #t)))))
(lambda (unload restart) (lambda (unload restart)