Skip to content

Commit

Permalink
35coreos-ignition: skip reboot if changed kargs match current boot
Browse files Browse the repository at this point in the history
If the requested kernel arguments in the Ignition config already match
the kernel arguments of the currently booted system then let's skip
the reboot because the reboot won't change anything.

One example of a use of this would be if someone is doing a PXE install
and they want to persistently use `net.ifnames=0`. They apply
`net.ifnames=0` on the PXE boot and coreos-installer transparently
forwards it to the Ignition boot (for a single boot). Then the Ignition
config has `net.ifnames=0` set in the kernel arguments section.
ignition-kargs.service will take care of setting it persistently,
but without this change the system will be rebooted. With this change
we skip the reboot.
  • Loading branch information
dustymabe committed Jan 7, 2022
1 parent e1207de commit 06bae91
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
#!/bin/bash
set -euo pipefail

# First check to see if the requested state is satisfied by the current boot
/usr/bin/rdcore kargs --current --create-if-changed /run/coreos-kargs-thisboot-differ "$@"

if is-live-image; then
/usr/bin/rdcore kargs --current --create-if-changed /run/coreos-kargs-changed "$@"
if [ -e /run/coreos-kargs-changed ]; then
# If we're in a live system and the kargs don't match then we must error.
if [ -e /run/coreos-kargs-thisboot-differ ]; then
echo "Need to modify kernel arguments, but cannot affect live system." >&2
exit 1
fi
else
/usr/bin/rdcore kargs --boot-device /dev/disk/by-label/boot --create-if-changed /run/coreos-kargs-reboot "$@"
/usr/bin/rdcore kargs --boot-device /dev/disk/by-label/boot --create-if-changed /run/coreos-kargs-changed "$@"
# If the bootloader was changed and the kernel arguments don't match this boot
# then we must reboot. If they do match this boot then we can skip the reboot.
if [ -e /run/coreos-kargs-changed ]; then
if [ -e /run/coreos-kargs-thisboot-differ ]; then
echo "Kernel arguments were changed. Requesting reboot."
touch /run/coreos-kargs-reboot
else
echo "Kernel arguments were changed, but they match this boot. Skipping reboot."
fi
fi
fi

0 comments on commit 06bae91

Please sign in to comment.