This repository has been archived by the owner on Aug 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce that Ignition run once even if interrupted
I have seen in practice us trying to run Ignition multiple times if the system is forcibly rebooted before we run the firstboot complete service, which actually today runs in the real rootfs. Forcibly prevent this by adding a few tiny new shell scripts which write a state file to `/boot/ignition.state`. The first to run is `ignition-prelaunch.service` which runs even before `fetch` and bombs out directly if we detect the stamp file exists. Next, we have a service which writes the stamp file after `fetch` and before `disks`. Finally, another service updates the stamp file just to signal `complete`. Note none of these services run on live systems, as there's no `/boot` there, and Ignition runs every boot anyways.
- Loading branch information
Showing
5 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[Unit] | ||
Description=Ignition (log completion) | ||
DefaultDependencies=false | ||
Before=ignition-complete.target | ||
After=basic.target | ||
|
||
After=ignition-files.service | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
MountFlags=slave | ||
TemporaryFileSystem=/run/boot | ||
# Flag completion of Ignition, so that we can immediately error out if we detect we started | ||
ExecStart=/bin/sh -c 'mount /dev/disk/by-label/boot /run/boot && echo completed > /run/boot/ignition.state' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[Unit] | ||
Description=Ignition (validate first run) | ||
DefaultDependencies=false | ||
Before=ignition-complete.target | ||
After=basic.target | ||
|
||
Before=ignition-fetch.service | ||
|
||
Requires=dev-disk-by\x2dlabel-boot.device | ||
After=dev-disk-by\x2dlabel-boot.device | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
MountFlags=slave | ||
TemporaryFileSystem=/run/boot | ||
# Flag completion of Ignition, so that we can immediately error out if we detect we started | ||
ExecStart=/bin/sh -c 'mount -o ro /dev/disk/by-label/boot /run/boot && if [ -f /run/boot/ignition.state ]; then echo -n "Detected previous run of Ignition:" $(cat /run/boot/ignition.state); exit 1; fi' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[Unit] | ||
Description=Ignition (log initiation) | ||
DefaultDependencies=false | ||
Before=ignition-complete.target | ||
After=basic.target | ||
|
||
# Run after ignition-setup has run because ignition-setup | ||
# may copy in new/different ignition configs for us to consume. | ||
After=ignition-fetch.service | ||
Before=ignition-disks.service | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
MountFlags=slave | ||
TemporaryFileSystem=/run/boot | ||
# Flag initiation of Ignition, so that we can immediately error out if we detect we started | ||
ExecStart=/bin/sh -c 'mount /dev/disk/by-label/boot /run/boot && echo started > /run/boot/ignition.state' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters