Skip to content

Commit

Permalink
Add new ignition-fetch-offline.service
Browse files Browse the repository at this point in the history
Make use of the new `fetch-offline` stage:

coreos/ignition#979

We run this between the `setup` and `fetch` stages (the latter possibly
being skipped if networking is not required).

We hit the same issue here that `coreos-copy-firstboot-network.service`
hit, which is that we can't run before the `cmdline` hook because that
runs *before* udev, but we want the `by-*` symlinks for
`ignition-setup-user.service`.

The hack we do here is to rerun the NM cmdline hook in case ignition
dropped a snippet in `/etc/cmdline.d`. As mentioned in
coreos/fedora-coreos-config#346, we'll be able
to do this more cleanly once we run NM as a systemd service directly.
  • Loading branch information
jlebon committed May 25, 2020
1 parent 1d34fc2 commit 3bd984b
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 18 deletions.
2 changes: 1 addition & 1 deletion dracut/30ignition/ignition-disks.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ConditionPathExists=/etc/initrd-release
DefaultDependencies=false
Before=ignition-complete.target

# Stage order: setup -> fetch -> disks -> mount -> files.
# Stage order: setup -> fetch-offline [-> fetch] -> disks -> mount -> files.
After=ignition-fetch.service
Before=ignition-mount.service

Expand Down
29 changes: 29 additions & 0 deletions dracut/30ignition/ignition-fetch-offline.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[Unit]
Description=Ignition (fetch-offline)
Documentation=https://github.com/coreos/ignition
ConditionPathExists=/etc/initrd-release
DefaultDependencies=false
Before=ignition-complete.target
After=basic.target

# Stage order: setup -> fetch-offline [-> fetch] -> disks -> mount -> files.
# We run after the setup stage has run because it may copy in new/different
# ignition configs for us to consume.
After=ignition-setup-base.service
After=ignition-setup-user.service
Before=ignition-fetch.service

# See hack below, as well as coreos-copy-firstboot-network.service.
After=dracut-cmdline.service
Before=dracut-initqueue.service

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/run/ignition.env
ExecStart=/usr/bin/ignition --root=/sysroot --platform=${PLATFORM_ID} --stage=fetch-offline
# Hack: we need to rerun the NM cmdline hook because we run after
# dracut-cmdline.service because we need udev. We should be able to move away
# from this once we run NM as a systemd unit. See also:
# https://github.com/coreos/fedora-coreos-config/pull/346#discussion_r409843428
ExecStart=/usr/bin/sh -c ". /usr/lib/dracut-lib.sh && . /usr/lib/dracut/hooks/cmdline/99-nm-config.sh"
9 changes: 4 additions & 5 deletions dracut/30ignition/ignition-fetch.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ ConditionPathExists=/etc/initrd-release
DefaultDependencies=false
Before=ignition-complete.target
After=basic.target
ConditionPathExists=/etc/cmdline.d/40-ignition-neednet.conf

# Stage order: setup -> fetch -> disks -> mount -> files.
# Stage order: setup -> fetch-offline [-> fetch] -> disks -> mount -> files.
# We run after the setup stage has run because it may copy in new/different
# ignition configs for us to consume.
After=ignition-setup-base.service
After=ignition-setup-user.service
After=ignition-fetch-offline.service
Before=ignition-disks.service


# Network may be used to fetch userdata content.
# If we run, it's that we definitely need network, so make sure we run after
After=network.target

[Service]
Expand Down
2 changes: 1 addition & 1 deletion dracut/30ignition/ignition-files.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ConditionPathExists=/etc/initrd-release
DefaultDependencies=false
Before=ignition-complete.target

# Stage order: setup -> fetch -> disks -> mount -> files.
# Stage order: setup -> fetch-offline [-> fetch] -> disks -> mount -> files.
After=ignition-mount.service

# Run before initrd-parse-etc so that we can drop files it then picks up.
Expand Down
14 changes: 7 additions & 7 deletions dracut/30ignition/ignition-mount.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ ConditionPathExists=/etc/initrd-release
DefaultDependencies=false
Before=ignition-complete.target

# Stage order: setup -> fetch-offline [-> fetch] -> disks -> mount -> files.
# We need to make sure the partitions and filesystems are set up before
# mounting. This is also guaranteed through After=initrd-root-fs.target but
# just to be explicit.
After=ignition-disks.service
Before=ignition-files.service

# Make sure ExecStop= runs before we switch root
Before=initrd-switch-root.target

Expand All @@ -19,13 +26,6 @@ After=initrd-root-fs.target
# Make sure root filesystem is remounted read-write if needed
After=ignition-remount-sysroot.service

# Stage order: setup -> fetch -> disks -> mount -> files.
# We need to make sure the partitions and filesystems are set up before
# mounting. This is also guaranteed through After=initrd-root-fs.target but
# just to be explicit.
After=ignition-disks.service
Before=ignition-files.service

[Service]
Type=oneshot
RemainAfterExit=yes
Expand Down
4 changes: 2 additions & 2 deletions dracut/30ignition/ignition-setup-base.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ ConditionPathExists=/etc/initrd-release
DefaultDependencies=false
Before=ignition-complete.target

# Stage order: setup -> fetch -> disks -> mount -> files.
Before=ignition-fetch.service
# Stage order: setup -> fetch-offline [-> fetch] -> disks -> mount -> files.
Before=ignition-fetch-offline.service

[Service]
Type=oneshot
Expand Down
4 changes: 2 additions & 2 deletions dracut/30ignition/ignition-setup-user.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ ConditionPathExists=/etc/initrd-release
DefaultDependencies=false
Before=ignition-complete.target

# Stage order: setup -> fetch -> disks -> mount -> files.
Before=ignition-fetch.service
# Stage order: setup -> fetch-offline [-> fetch] -> disks -> mount -> files.
Before=ignition-fetch-offline.service

# We want to make sure we're not racing with multipath taking ownership of the
# boot device.
Expand Down
1 change: 1 addition & 0 deletions dracut/30ignition/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ install() {
install_ignition_unit ignition-setup-base.service
install_ignition_unit ignition-setup-user.service
install_ignition_unit ignition-fetch.service
install_ignition_unit ignition-fetch-offline.service
install_ignition_unit ignition-disks.service
install_ignition_unit ignition-mount.service
install_ignition_unit ignition-files.service
Expand Down

0 comments on commit 3bd984b

Please sign in to comment.