New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
98dracut-systemd: don't wait for root device if remote cryptsetup active #931
Conversation
|
Can one of the admins verify this patch? |
|
Consider this an RFC; I'm likely missing some backstory here. I looked a bit at the git logs for both this file and systemd's |
|
/cc @sergio-correia |
|
/cc @poettering who likely has better context on this. |
|
Hmm, the
|
Ahh OK, the The case I'm interested in however is the one where IOW, WDYT of this patch: diff --git a/modules.d/98dracut-systemd/dracut-pre-mount.service b/modules.d/98dracut-systemd/dracut-pre-mount.service
index 18c9730c..6a0cdb0b 100644
--- a/modules.d/98dracut-systemd/dracut-pre-mount.service
+++ b/modules.d/98dracut-systemd/dracut-pre-mount.service
@@ -7,7 +7,7 @@ Description=dracut pre-mount hook
Documentation=man:dracut-pre-mount.service(8)
DefaultDependencies=no
Before=initrd-root-fs.target sysroot.mount systemd-fsck-root.service
-After=dracut-initqueue.service cryptsetup.target
+After=dracut-initqueue.service cryptsetup.target initrd-root-device.target
ConditionPathExists=/usr/lib/initrd-release
ConditionDirectoryNotEmpty=|/lib/dracut/hooks/pre-mount
ConditionKernelCommandLine=|rd.break=pre-mount
diff --git a/modules.d/98dracut-systemd/rootfs-generator.sh b/modules.d/98dracut-systemd/rootfs-generator.sh
index 4ae693bb..42f56fe1 100755
--- a/modules.d/98dracut-systemd/rootfs-generator.sh
+++ b/modules.d/98dracut-systemd/rootfs-generator.sh
@@ -111,10 +111,11 @@ esac
GENERATOR_DIR="$1"
-if [ "$rootok" = "1" ]; then
+# Only handle root= if it's in /etc/cmdline.d. Otherwise, systemd handles it.
+if [ "$rootok" = "1" ] && ! strstr "$(cat /proc/cmdline)" 'root='; then
generator_wait_for_dev "${root#block:}" "$RDRETRY"
generator_fsck_after_pre_mount "${root#block:}"
- strstr "$(cat /proc/cmdline)" 'root=' || generator_mount_rootfs "${root#block:}" "$(getarg rootfstype=)" "$(getarg rootflags=)"
+ generator_mount_rootfs "${root#block:}" "$(getarg rootfstype=)" "$(getarg rootflags=)"
fi
exit 0? That way, we make sure systemd and dracut don't step on each other's toes. :) |
|
Looks like a plan. Let's do it and see what fails :-/ |
|
OK updated! Sanity-checked also that this fixes my use case. |
|
As you see in the test suite, there are a lot of setups, which are unhappy about the change. As mentioned, the systemd device timeout has to be corrected, so that fallback jobs (like assembling a degraded raid) can be executed. |
77c9d8a
to
43c6f08
Compare
This is a plain and simple hack around dependency issues between dracut
and systemd.
When using Tang-pinned LUKS root devices, we want to rely on
`systemd-cryptsetup@.service` to unlock it. However, that service only
runs `After=remote-fs-pre.target`, while `dracut-initqueue.service` has
`Before=remote-fs-pre.target` (which makes sense because we don't want
to attempt networked root devices before networking is up).
However, the rootfs-generator here wants to make sure that the root
device exists *before* exiting the initqueue via an initqueue/finished
"devexists" hook. This will never work though because by design
`systemd-cryptsetup@.service`, which unlocks the root device, won't run
until after we exit.
So we have a dependency cycle:
initqueue -> devexists hook -> root device ->
systemd-cryptsetup@.service -> remote-fs-pre.target -> initqueue
There's no clean way to break this. The root issue is that there's no
way right now to split sequencing of systemd services across the
initqueue/online and initqueue/finished events because it's all bundled
in a single service. (The deeper root issue of course is that we have
two init systems. :) ).
Here we do a tactical fix: if there's a `systemd-cryptsetup@.service`
instance, let's assume it's for the root device and skip waiting for it
to show up if it depends on `remote-fs-pre.target`.
|
OK, switched strategy on this now for a more tactical fix. And went a bit more in depth in the commit message. |
|
@jlebon Thanks! Let's give it a try. |
- Drop the TPM test since it's already covered by the external host test which are inherited from FCOS - Move to new way of defining LUKS devices - Dedupe a bunch of things The test is currently limited to RHCOS but once we have the requisite patches in dracut and systemd in FCOS, we should be able to target it too: dracutdevs/dracut#931 dracutdevs/dracut#968 systemd/systemd#17467
- Drop the TPM test since it's already covered by the external host test which are inherited from FCOS - Move to new way of defining LUKS devices - Dedupe a bunch of things The test is currently limited to RHCOS but once we have the requisite patches in dracut and systemd in FCOS, we should be able to target it too: dracutdevs/dracut#931 dracutdevs/dracut#968 systemd/systemd#17467
- Drop the TPM test since it's already covered by the external host test which are inherited from FCOS - Move to new way of defining LUKS devices - Dedupe a bunch of things The test is currently limited to RHCOS but once we have the requisite patches in dracut and systemd in FCOS, we should be able to target it too: dracutdevs/dracut#931 dracutdevs/dracut#968 systemd/systemd#17467
This is a plain and simple hack around dependency issues between dracut
and systemd.
When using Tang-pinned LUKS root devices, we want to rely on
systemd-cryptsetup@.serviceto unlock it. However, that service onlyruns
After=remote-fs-pre.target, whiledracut-initqueue.servicehasBefore=remote-fs-pre.target(which makes sense because we don't wantto attempt networked root devices before networking is up).
However, the rootfs-generator here wants to make sure that the root
device exists before exiting the initqueue via an initqueue/finished
"devexists" hook. This will never work though because by design
systemd-cryptsetup@.service, which unlocks the root device, won't rununtil after we exit.
So we have a dependency cycle:
There's no clean way to break this. The root issue is that there's no
way right now to split sequencing of systemd services across the
initqueue/online and initqueue/finished events because it's all bundled
in a single service. (The deeper root issue of course is that we have
two init systems. :) ).
Here we do a tactical fix: if there's a
systemd-cryptsetup@.serviceinstance, let's assume it's for the root device and skip waiting for it
to show up if it depends on
remote-fs-pre.target.