finalize-staged: Ensure /boot automount doesn't expire

If `/boot` is an automount, then the unit will be stopped as soon as the
automount expires. That's would defeat the purpose of using systemd to
delay finalizing the deployment until shutdown. This is not uncommon as
`systemd-gpt-auto-generator` will create an automount unit for `/boot`
when it's the EFI System Partition and there's no fstab entry.

To ensure that systemd doesn't stop the service early when the `/boot`
automount expires, introduce a new unit that holds `/boot` open until
it's sent `SIGTERM`. This uses a new `--hold` option for
`finalize-staged` that loads but doesn't lock the sysroot. A separate
unit is used since we want the process to remain active throughout the
finalization run in `ExecStop`. That wouldn't work if it was specified
in `ExecStart` in the same unit since it would be killed before the
`ExecStop` action was run.

Fixes: #2543
This commit is contained in:
Dan Nicholson committed 2022-08-30 09:16:39 -06:00
1 parent e30a3b6b17
commit f3db79e7fa
6 files changed
+193 -7

No files matched your search

+5 -2
View File
@@ -463,6 +463,7 @@ fn impl_transaction_test<M: AsRef<str>>(
"
systemctl stop rpm-ostreed
systemctl stop ostree-finalize-staged
systemctl stop ostree-finalize-staged-hold
ostree reset testrepo:${testref} ${booted_commit}
rpm-ostree cleanup -pbrm
",
@@ -504,7 +505,8 @@ fn impl_transaction_test<M: AsRef<str>>(
InterruptStrategy::Force(ForceInterruptStrategy::Kill9) => {
bash!(
"systemctl kill -s KILL rpm-ostreed || true
systemctl kill -s KILL ostree-finalize-staged || true"
systemctl kill -s KILL ostree-finalize-staged || true
systemctl kill -s KILL ostree-finalize-staged-hold || true"
)?;
live_strategy = Some(strategy);
}
@@ -528,7 +530,8 @@ fn impl_transaction_test<M: AsRef<str>>(
InterruptStrategy::Polite(PoliteInterruptStrategy::Stop) => {
bash!(
"systemctl stop rpm-ostreed || true
systemctl stop ostree-finalize-staged || true"
systemctl stop ostree-finalize-staged || true
systemctl stop ostree-finalize-staged-hold || true"
)?;
live_strategy = Some(strategy);
}