Skip to content

Commit

Permalink
05core: make coreos-secex-ignition-decrypt.service virtio device dep …
Browse files Browse the repository at this point in the history
…explicit

The decryption script requires the encrypted Ignition virtio device to be
present. Previously, we used `Before=coreos-gpt-setup.service`, which I
think ran late enough that the device would always be present by then.
But we've now moved that service and `After=systemd-udevd.service` isn't
good enough so the service now fails because the device doesn't exist.

Fix this by directly listing the requirement on the device in
the unit, which is more explicit anyway. And because of systemd's
"ConditionPathExists don't turn off Requires" semantic, make the unit
dynamically enabled by the diskful generator. As a bonus, we now have
one less service in the default initramfs transaction (which actually
was getting pulled in on all arches too).
  • Loading branch information
jlebon authored and cgwalters committed Nov 6, 2023
1 parent b509dbe commit 48ad3a3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,9 @@ StandardOutput=null
StandardError=null
EOF
done

# This one is done dynamically because it hard Requires a device to appear
# and if it's always part of the transaction, systemd will want the device
# to appear regardless of ConditionPathExists.
add_requires coreos-secex-ignition-decrypt.service ignition-diskful.target
fi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This service is enabled by coreos-diskful-generator

[Unit]
Description=CoreOS Secex Ignition Config Decryptor
ConditionPathExists=/etc/initrd-release
Expand All @@ -7,8 +9,9 @@ DefaultDependencies=false
OnFailure=emergency.target
OnFailureJobMode=isolate

# Run after udevd and before Ignition
After=systemd-udevd.service
# Run after the crypt device becomes available and before Ignition
Requires=dev-disk-by\x2did-virtio\x2dignition_crypted.device
After=dev-disk-by\x2did-virtio\x2dignition_crypted.device
Before=ignition-fetch-offline.service

[Service]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ install() {

# IBM Secure Execution. Ignition config for reencryption of / and /boot
inst_simple "$moddir/01-secex.ign" /usr/lib/coreos/01-secex.ign
install_ignition_unit "coreos-secex-ignition-decrypt.service"
inst_simple "$moddir/coreos-secex-ignition-decrypt.service" \
"$systemdsystemunitdir/coreos-secex-ignition-decrypt.service"
inst_script "$moddir/coreos-secex-ignition-decrypt.sh" \
"/usr/sbin/coreos-secex-ignition-decrypt"

Expand Down

0 comments on commit 48ad3a3

Please sign in to comment.