initrd: add failure mode to `nm-initrd-generator` for invalid input
If I give an invalid input to nm-initrd-generator
then I get a warning but no error.
For example if I give it an invalid input (like ip=ens2:dhcp:52:54:00:00:af:00
, which is missing a :
) I get:
[core@cosa-devsh ~]$ /usr/libexec/nm-initrd-generator -s -- ip=ens2:dhcp:52:54:00:00:af:00
802-3-ethernet.cloned-mac-address: '54:00:00:af:00' is not a valid MAC address
[core@cosa-devsh ~]$ echo $?
0
With the legacy network dracut module it ignores it but it does still create a ifcfg-ens2
file. So it also does not stop the boot. Though in some cases the legacy network module will halt the boot. For example if I provide rd.neednet=1 ip=ens2:dhcp ip=ens3:off
to the legacy network module then on boot I get:
[ 4.460200] dracut-cmdline[332]: Multiple ip= arguments: assuming rd.neednet=1
[ 4.466540] dracut-cmdline[332]: Setting bootdev to 'ens2'
[ 4.469864] dracut-cmdline[332]: Warning: Empty autoconf values default to dhcp
[ 4.472181] dracut-cmdline[332]: Warning: Empty autoconf values default to dhcp
[ 4.475287] dracut: FATAL: Sorry, 'ip=ens3:off' does not make sense for multiple interface configurations
[ 4.477716] dracut: Refusing to continue
[ 4.518998] systemd[1]: Shutting down.
So there is at least some precedent for stopping boot if it gets invalid input (though note with the NM dracut module ip=ens2:dhcp ip=ens3:off
is valid).
In Fedora CoreOS I think we want failures in the run of nm-initrd-generator
to be considered a failure case and not have the machine continue boot. I realize NetworkManager might not want to change the defaults for everyone so maybe we have a few different options:
- NM changes the default behavior to fail and stop the boot if it gets invalid input when running
nm-initrd-generator
. - NM doesn't change the default behavior, but adds a new option to
nm-initrd-generator
to output a different exit-code if it encountered invalid input. Maybe the dracut module could then touch a file/tmp/nm-initrd-generator-invalid-input
if this error case occurs. Then Fedora CoreOS boot processes could detect this and act appropriately.