Skip to content

Commit

Permalink
os, release: reboot host if needed after reaching configured.target
Browse files Browse the repository at this point in the history
Reboot the system towards the end of the configuration phase during boot
if any of the first-party components deem this necessary. The reboot is
enacted after reaching the configured.target and before reaching the
multi-user.target, so e.g. user data has been applied and bootstrap
containers have already run, but the host is not yet fully operational.

Components can hook into the new reboot-if-required.service to be able
to run at this point. They should implement a "reboot-if-required"
command to trigger a reboot if it is needed.

Currently, prairiedog is the only component hook into this service and
implement a "reboot-if-required" command. It will trigger a reboot if
boot settings have changed, i.e. if the kernel or systemd command line
arguments were changed via the user data mechanism or a bootstrap
container.

Signed-off-by: Markus Boehme <[email protected]>
  • Loading branch information
markusboehme committed Sep 9, 2022
1 parent fb135c7 commit 4e174f0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/os/os.spec
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Source116: load-kernel-modules.service.in
Source117: cfsignal.service
Source118: generate-network-config.service
Source119: prepare-primary-interface.service
Source120: reboot-if-required.service

# 2xx sources: tmpfilesd configs
Source200: migration-tmpfiles.conf
Expand Down Expand Up @@ -429,7 +430,7 @@ install -d %{buildroot}%{_cross_unitdir}
install -p -m 0644 \
%{S:100} %{S:101} %{S:102} %{S:103} %{S:105} \
%{S:106} %{S:107} %{S:110} %{S:111} %{S:112} \
%{S:113} %{S:114} %{S:118} %{S:119} \
%{S:113} %{S:114} %{S:118} %{S:119} %{S:120} \
%{buildroot}%{_cross_unitdir}

%if %{_is_vendor_variant}
Expand Down Expand Up @@ -590,6 +591,7 @@ install -p -m 0644 %{S:300} %{buildroot}%{_cross_udevrulesdir}/80-ephemeral-stor

%files -n %{_cross_os}prairiedog
%{_cross_bindir}/prairiedog
%{_cross_unitdir}/reboot-if-required.service

%files -n %{_cross_os}certdog
%{_cross_bindir}/certdog
Expand Down
11 changes: 11 additions & 0 deletions packages/os/reboot-if-required.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Reboot system if needed for configuration changes to take effect
# Block manual interactions for now to prevent unplanned reboots.
RefuseManualStart=true
RefuseManualStop=true
After=configured.target

[Service]
Type=oneshot
ExecStart=/usr/bin/prairiedog reboot-if-required
StandardError=journal+console
4 changes: 2 additions & 2 deletions packages/release/activate-multi-user.service
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Unit]
Description=Isolates multi-user.target
After=configured.target
Requires=configured.target
After=configured.target reboot-if-required.service
Requires=configured.target reboot-if-required.service

[Service]
Type=oneshot
Expand Down

0 comments on commit 4e174f0

Please sign in to comment.