From 849061f41aff75ab1649ed4ba2bbcb7b804389d5 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Mon, 25 May 2020 11:57:11 -0400 Subject: [PATCH] Move to conditional networking We have all the piece in place now to move to conditional networking. So let's drop the firstboot kargs, as well as coreos-liveiso-network-kargs.service, which is no longer needed (i.e. the live ISO will now enable initrd networking as required given the embedded Ignition config). Fixes: https://github.com/coreos/fedora-coreos-tracker/issues/443 --- image.yaml | 7 ++- .../coreos-liveiso-network-kargs.service | 45 ------------------- .../20live/coreos-liveiso-network-kargs.sh | 24 ---------- .../dracut/modules.d/20live/live-generator | 1 - .../dracut/modules.d/20live/module-setup.sh | 6 --- .../system/coreos-liveiso-success.service | 3 +- 6 files changed, 4 insertions(+), 82 deletions(-) delete mode 100644 overlay.d/05core/usr/lib/dracut/modules.d/20live/coreos-liveiso-network-kargs.service delete mode 100755 overlay.d/05core/usr/lib/dracut/modules.d/20live/coreos-liveiso-network-kargs.sh diff --git a/image.yaml b/image.yaml index 37aaedb51..a91ab3202 100644 --- a/image.yaml +++ b/image.yaml @@ -9,10 +9,9 @@ extra-kargs: # https://fedoraproject.org/wiki/Changes/CGroupsV2 - systemd.unified_cgroup_hierarchy=0 -# Kernel arguments to be used on first-boot. -ignition-network-kcmdline: - - 'rd.neednet=1' - - 'ip=dhcp,dhcp6' +# Disable networking by default on firstboot. We can drop this once cosa stops +# defaulting to `ip=dhcp,dhcp6 rd.neednet=1` when it doesn't see this key. +ignition-network-kcmdline: [] # Optional remote by which to prefix the deployed OSTree ref ostree-remote: fedora diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/20live/coreos-liveiso-network-kargs.service b/overlay.d/05core/usr/lib/dracut/modules.d/20live/coreos-liveiso-network-kargs.service deleted file mode 100644 index 72ac3c3cf..000000000 --- a/overlay.d/05core/usr/lib/dracut/modules.d/20live/coreos-liveiso-network-kargs.service +++ /dev/null @@ -1,45 +0,0 @@ -# This unit will run very early before the dracut-cmdline -# service and detect if we want to request dracut bring up -# networking or not. We do want to request networking if: -# -# - the user is booting the live ISO -# - the user didn't already request networking via rd.neednet -# - the user provided a ignition.config.url karg, implying -# the need for networking -# -# As of recently we skip networking if a config is injected via -# `coreos-installer iso embed` in order to allow automating -# installs on networks without DHCP. -# -# If we do determine we need network and there are no other -# `ip=` kargs then we'll use `ip=dhcp,dhcp6` by default. -# -# The requesting of network will be done by writing relevant -# dracut networking args into /etc/cmdline.d/coreos-live-network-kargs.conf -# so that it gets picked up by the dracut networking scripts later -# on in boot. -# -# This is all done because we want to support a mode where -# the user can boot the live ISO and get to an interactive -# prompt without requiring networking on boot. The user can -# then configure the networking interactively. -# -[Unit] -Description=Request live ISO networking -DefaultDependencies=no -Before=dracut-cmdline.service - -# Make sure we are in the initramfs. We are booted to the live -# ISO and rd.neednet wasn't already passed somewhere else -ConditionPathExists=/usr/lib/initrd-release -ConditionKernelCommandLine=!rd.neednet -ConditionKernelCommandLine=coreos.liveiso -ConditionPathExists=/run/ostree-live - -# We'll assume we need network in the following case (see description from above) -ConditionKernelCommandLine=|ignition.config.url - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=/usr/sbin/coreos-liveiso-network-kargs diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/20live/coreos-liveiso-network-kargs.sh b/overlay.d/05core/usr/lib/dracut/modules.d/20live/coreos-liveiso-network-kargs.sh deleted file mode 100755 index 9049686ad..000000000 --- a/overlay.d/05core/usr/lib/dracut/modules.d/20live/coreos-liveiso-network-kargs.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/bash - -# For a description of how this is used see coreos-liveiso-network-kargs.service - -# Load the dracut library for getarg -source /usr/lib/dracut-lib.sh - -main() { - - # If we're running this script we already know we need networking - # (determined by conditionals in the systemd unit). - echo 'info: Requesting networking in the initramfs' - echo 'rd.neednet=1' > /etc/cmdline.d/10-coreos-liveiso-network-kargs.conf - - # If there is not already a ip= CLI arg use ip=dhcp,dhcp6 as default. - if ! getarg 'ip' &>/dev/null; then - echo 'info: using ip=dhcp,dhcp6 default networking configuration' - echo 'ip=dhcp,dhcp6' >> /etc/cmdline.d/10-coreos-liveiso-network-kargs.conf - else - echo 'info: using already set karg ip= information' - fi -} - -main diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/20live/live-generator b/overlay.d/05core/usr/lib/dracut/modules.d/20live/live-generator index 90ac7418c..f61326afc 100755 --- a/overlay.d/05core/usr/lib/dracut/modules.d/20live/live-generator +++ b/overlay.d/05core/usr/lib/dracut/modules.d/20live/live-generator @@ -31,7 +31,6 @@ add_requires sysroot.mount initrd-root-fs.target add_requires sysroot-etc.mount initrd-root-fs.target add_requires sysroot-var.mount initrd-root-fs.target -add_requires coreos-liveiso-network-kargs.service initrd.target add_requires coreos-liveiso-reconfigure-nm-wait-online.service initrd.target mkdir -p "${UNIT_DIR}/ostree-prepare-root.service.d" diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/20live/module-setup.sh b/overlay.d/05core/usr/lib/dracut/modules.d/20live/module-setup.sh index d49b0571c..dcb4cc6b2 100644 --- a/overlay.d/05core/usr/lib/dracut/modules.d/20live/module-setup.sh +++ b/overlay.d/05core/usr/lib/dracut/modules.d/20live/module-setup.sh @@ -34,12 +34,6 @@ install() { inst_simple "$moddir/writable.mount" \ "$systemdsystemunitdir/writable.mount" - inst_simple "$moddir/coreos-liveiso-network-kargs.sh" \ - "/usr/sbin/coreos-liveiso-network-kargs" - - inst_simple "$moddir/coreos-liveiso-network-kargs.service" \ - "$systemdsystemunitdir/coreos-liveiso-network-kargs.service" - inst_simple "$moddir/coreos-liveiso-reconfigure-nm-wait-online.service" \ "$systemdsystemunitdir/coreos-liveiso-reconfigure-nm-wait-online.service" } diff --git a/overlay.d/05core/usr/lib/systemd/system/coreos-liveiso-success.service b/overlay.d/05core/usr/lib/systemd/system/coreos-liveiso-success.service index befc41e79..a3db8673a 100644 --- a/overlay.d/05core/usr/lib/systemd/system/coreos-liveiso-success.service +++ b/overlay.d/05core/usr/lib/systemd/system/coreos-liveiso-success.service @@ -4,8 +4,7 @@ [Unit] Description=CoreOS Live ISO virtio success Documentation=https://github.com/coreos/fedora-coreos-config -# Only run on the Live ISO, and only if there's no Ignition config; -# the second bits here invert the conditionals in coreos-liveiso-network-kargs.service. +# Only run on the Live ISO, and only if there's no Ignition config ConditionKernelCommandLine=coreos.liveiso ConditionPathExists=!/config.ign ConditionVirtualization=|kvm