[PATCH] services: admin: Support restarting system after unattended upgrade

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Richard Sent
Owner
unassigned
Submitted by
Richard Sent
Severity
normal
R
R
Richard Sent wrote on 28 Apr 23:32 +0200
(address . guix-patches@gnu.org)(name . Richard Sent)(address . richard@freakingpenguin.com)
4852ee6c60830311f4f1f06a43af9b471e91ad88.1714339967.git.richard@freakingpenguin.com
* gnu/services/admin.scm (unattended-upgrade-configuration): Add restart?
field. When truthy, unattended upgrade will tell shepherd to stop the root
service, which triggers a restart.
* /doc/guix.texi (Unattended Upgrades): Document it.

Change-Id: I0af659b3c318421b1a7baa94dde3dadacc1fa10d
---
Hi Guix!

This patch adds support for running a complete system restart after an
unattended upgrade. Previously, unattended upgrades were not capable
of, say, upgrading the kernel.

/Technically/ without this patch I'm pretty sure you could restart the
system by restarting the 'file-systems service. I haven't found
documentation on that and it feels like a hack more than a feature. I
don't know if it would perform a safe shutdown. Thankfully, Shepherd
explicitly treats "stop root service" as "restart" so the method in
this patch should be safe.

doc/guix.texi | 4 ++++
gnu/services/admin.scm | 13 ++++++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)

Toggle diff (57 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 3ee9f54773..08fdac4cd3 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -22891,6 +22891,10 @@ Unattended Upgrades
#~(@@ (guix system install) installation-os)))
@end lisp
+@item @code{restart?} (default: @code{#f})
+This field specifies whether the system should restart after completing
+an unattended upgrade.
+
@item @code{services-to-restart} (default: @code{'(mcron)})
This field specifies the Shepherd services to restart when the upgrade
completes.
diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index 0b325fddb1..579cf83132 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -420,6 +420,8 @@ (define-record-type* <unattended-upgrade-configuration>
(default "30 01 * * 0"))
(channels unattended-upgrade-configuration-channels
(default #~%default-channels))
+ (restart? unattended-upgrade-configuration-restart?
+ (default #f))
(services-to-restart unattended-upgrade-configuration-services-to-restart
(default '(mcron)))
(system-expiration unattended-upgrade-system-expiration
@@ -443,6 +445,9 @@ (define (unattended-upgrade-mcron-jobs config)
(define services
(unattended-upgrade-configuration-services-to-restart config))
+ (define restart?
+ (unattended-upgrade-configuration-restart? config))
+
(define expiration
(unattended-upgrade-system-expiration config))
@@ -512,7 +517,13 @@ (define (unattended-upgrade-mcron-jobs config)
;; XXX: If 'mcron' has been restarted, perhaps this isn't
;; reached.
- (format #t "~a upgrade complete~%" (timestamp))))))
+ (format #t "~a upgrade complete~%" (timestamp))
+
+ ;; Stopping the root shepherd service triggers a restart.
+ (when #$restart?
+ (format #t "~a restarting system~%" (timestamp))
+ (force-output) ;ensure the entire log is written.
+ (stop-service 'root))))))
(define upgrade
(program-file "unattended-upgrade" code))

base-commit: 9f183c3627a006e8fd3bb9708448bc05a6204e6d
--
2.41.0
R
R
Richard Sent wrote on 29 Apr 06:34 +0200
[PATCH v2] services: admin: Support rebooting after an unattended upgrade
(address . 70636@debbugs.gnu.org)(name . Richard Sent)(address . richard@freakingpenguin.com)
8e12822dfa63081eaca99f204a78965fc6db3a01.1714365260.git.richard@freakingpenguin.com
* gnu/services/admin.scm (unattended-upgrade-configuration): Add reboot?
field. When truthy, unattended upgrade will stop the shepherd root service,
triggering a reboot.
* doc/guix.texi (Unattended Upgrades): Document it.

Change-Id: I0af659b3c318421b1a7baa94dde3dadacc1fa10d
---
Decided to change restart? to reboot?. The manual seems to generally
prefer reboot and it makes restarting services vs. rebooting the
system a bit more distinct.

doc/guix.texi | 4 ++++
gnu/services/admin.scm | 13 ++++++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)

Toggle diff (57 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 5d3c9225b4..709db674c9 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -22891,6 +22891,10 @@ Unattended Upgrades
#~(@@ (guix system install) installation-os)))
@end lisp
+@item @code{reboot?} (default: @code{#f})
+This field specifies whether the system should reboot after completing
+an unattended upgrade.
+
@item @code{services-to-restart} (default: @code{'(mcron)})
This field specifies the Shepherd services to restart when the upgrade
completes.
diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index 0b325fddb1..4882883878 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -420,6 +420,8 @@ (define-record-type* <unattended-upgrade-configuration>
(default "30 01 * * 0"))
(channels unattended-upgrade-configuration-channels
(default #~%default-channels))
+ (reboot? unattended-upgrade-configuration-reboot?
+ (default #f))
(services-to-restart unattended-upgrade-configuration-services-to-restart
(default '(mcron)))
(system-expiration unattended-upgrade-system-expiration
@@ -443,6 +445,9 @@ (define (unattended-upgrade-mcron-jobs config)
(define services
(unattended-upgrade-configuration-services-to-restart config))
+ (define reboot?
+ (unattended-upgrade-configuration-reboot? config))
+
(define expiration
(unattended-upgrade-system-expiration config))
@@ -512,7 +517,13 @@ (define (unattended-upgrade-mcron-jobs config)
;; XXX: If 'mcron' has been restarted, perhaps this isn't
;; reached.
- (format #t "~a upgrade complete~%" (timestamp))))))
+ (format #t "~a upgrade complete~%" (timestamp))
+
+ ;; Stopping the root shepherd service triggers a reboot.
+ (when #$reboot?
+ (format #t "~a rebooting system~%" (timestamp))
+ (force-output) ;ensure the entire log is written.
+ (stop-service 'root))))))
(define upgrade
(program-file "unattended-upgrade" code))

base-commit: 3bd8d238aba718bf949691d0e37fa310e2cfc12a
--
2.41.0
L
L
Ludovic Courtès wrote on 15 Sep 23:53 +0200
(name . Richard Sent)(address . richard@freakingpenguin.com)(address . 70636-done@debbugs.gnu.org)
87jzfcbn34.fsf@gnu.org
Hi,

Richard Sent <richard@freakingpenguin.com> skribis:

Toggle quote (7 lines)
> * gnu/services/admin.scm (unattended-upgrade-configuration): Add reboot?
> field. When truthy, unattended upgrade will stop the shepherd root service,
> triggering a reboot.
> * doc/guix.texi (Unattended Upgrades): Document it.
>
> Change-Id: I0af659b3c318421b1a7baa94dde3dadacc1fa10d

Applied, thanks!

Ludo’.
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 70636@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 70636
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch