Skip to content

Commit 06bae91

Browse files
committed
35coreos-ignition: skip reboot if changed kargs match current boot
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.
1 parent e1207de commit 06bae91

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed
Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
#!/bin/bash
22
set -euo pipefail
33

4+
# First check to see if the requested state is satisfied by the current boot
5+
/usr/bin/rdcore kargs --current --create-if-changed /run/coreos-kargs-thisboot-differ "$@"
6+
47
if is-live-image; then
5-
/usr/bin/rdcore kargs --current --create-if-changed /run/coreos-kargs-changed "$@"
6-
if [ -e /run/coreos-kargs-changed ]; then
8+
# If we're in a live system and the kargs don't match then we must error.
9+
if [ -e /run/coreos-kargs-thisboot-differ ]; then
710
echo "Need to modify kernel arguments, but cannot affect live system." >&2
811
exit 1
912
fi
1013
else
11-
/usr/bin/rdcore kargs --boot-device /dev/disk/by-label/boot --create-if-changed /run/coreos-kargs-reboot "$@"
14+
/usr/bin/rdcore kargs --boot-device /dev/disk/by-label/boot --create-if-changed /run/coreos-kargs-changed "$@"
15+
# If the bootloader was changed and the kernel arguments don't match this boot
16+
# then we must reboot. If they do match this boot then we can skip the reboot.
17+
if [ -e /run/coreos-kargs-changed ]; then
18+
if [ -e /run/coreos-kargs-thisboot-differ ]; then
19+
echo "Kernel arguments were changed. Requesting reboot."
20+
touch /run/coreos-kargs-reboot
21+
else
22+
echo "Kernel arguments were changed, but they match this boot. Skipping reboot."
23+
fi
24+
fi
1225
fi

0 commit comments

Comments
 (0)