Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Add new ignition-fetch-offline.service #164

Merged
merged 2 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dracut/30ignition/coreos-teardown-initramfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ load_dracut_libs() {
dracut_func() {
# dracut is not friendly to set -eu
set +euo pipefail
"$@"; rc=$?
"$@"; local rc=$?
set -euo pipefail
return $rc
}
Expand Down
27 changes: 27 additions & 0 deletions dracut/30ignition/ignition-check-neednet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
set -euo pipefail

set +euo pipefail
. /usr/lib/dracut-lib.sh
set -euo pipefail

dracut_func() {
# dracut is not friendly to set -eu
set +euo pipefail
"$@"; local rc=$?
set -euo pipefail
return $rc
}

# If we need networking and it hasn't been requested yet, request it.
if [ -f /run/ignition/neednet ] && ! dracut_func getargbool 0 'rd.neednet'; then
jlebon marked this conversation as resolved.
Show resolved Hide resolved
echo "rd.neednet=1" > /etc/cmdline.d/40-ignition-neednet.conf

# 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
set +euo pipefail
. /usr/lib/dracut/hooks/cmdline/99-nm-config.sh
set -euo pipefail
fi
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
28 changes: 28 additions & 0 deletions dracut/30ignition/ignition-fetch-offline.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[Unit]
Description=Ignition (fetch-offline)
jlebon marked this conversation as resolved.
Show resolved Hide resolved
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

OnFailure=emergency.target
OnFailureJobMode=isolate

# See hack in ignition-check-neednet, 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
ExecStart=/usr/sbin/ignition-check-neednet
8 changes: 4 additions & 4 deletions dracut/30ignition/ignition-fetch.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ ConditionPathExists=/etc/initrd-release
DefaultDependencies=false
Before=ignition-complete.target
After=basic.target
ConditionPathExists=/run/ignition/neednet

# 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

OnFailure=emergency.target
OnFailureJobMode=isolate

# Network may be used to fetch userdata content.
# If we run, 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 @@ -8,7 +8,7 @@ Before=ignition-complete.target
OnFailure=emergency.target
OnFailureJobMode=isolate

# 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 @@ -18,13 +25,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 @@ -8,8 +8,8 @@ Before=ignition-complete.target
OnFailure=emergency.target
OnFailureJobMode=isolate

# 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 @@ -8,8 +8,8 @@ Before=ignition-complete.target
OnFailure=emergency.target
OnFailureJobMode=isolate

# 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
3 changes: 3 additions & 0 deletions dracut/30ignition/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ install() {
"/usr/sbin/ignition-setup-base"
inst_script "$moddir/ignition-setup-user.sh" \
"/usr/sbin/ignition-setup-user"
inst_script "$moddir/ignition-check-neednet.sh" \
"/usr/sbin/ignition-check-neednet"

# Distro packaging is expected to install the ignition binary into the
# module directory.
Expand All @@ -72,6 +74,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
jlebon marked this conversation as resolved.
Show resolved Hide resolved
install_ignition_unit ignition-disks.service
install_ignition_unit ignition-mount.service
install_ignition_unit ignition-files.service
Expand Down