From c5b372a28fabfe7b490fdded7af9ca8c362b793f Mon Sep 17 00:00:00 2001 From: Jeffrey Sica Date: Sat, 26 Sep 2026 12:14:36 -0500 Subject: [PATCH] fix(installer): actually wait for the network before the DDI download systemd-networkd-wait-online lives in /usr/lib/systemd and is not on PATH in the installer initrd, so the `command -v` guard around it never fired, the wait was silently skipped and curl raced the DHCP lease: curl: (7) Could not connect to server 11 s after boot on a bridged network, with the released installer-v26.08.0 PXE initrd. Call the binary by its absolute path and drop the guard; a missing binary is now a build failure (checked next to the other critical tools in step 1a) rather than a skipped wait at install time. Calling the binary from the wrapper keeps the wait conditional on inst.ddi_url (offline USB installs must not wait); the systemd-networkd-wait-online.service route would need a ConditionKernelCommandLine= plus an ExecStart= drop-in for the flags and Requires= to abort the install on failure. Pass --any --ipv4. The installer's 80-dhcp.network matches every en*/eth*/ens*/enp* interface, and wait-online without --any keeps waiting while any managed link is still in setup state "configuring" (wait-online-manager.c manager_configured(): -EBUSY makes it return false, so the wait runs to --timeout unless --any). An unplugged second NIC sits at "no-carrier configuring" forever, so now that the wait really runs it would abort every PXE install on such a machine after 90 s. With --any the wait returns once one managed link is "configured". That alone is not enough: networkd marks a link configured as soon as one dynamic protocol finished (link_check_ready()), so on a LAN with router advertisements a SLAAC or DHCPv6 address makes the link configured before the DHCPv4 lease and curl http:// would race again; --ipv4 requires the satisfying link to carry an IPv4 address, which with IPv4LL disabled means the DHCPv4 lease. The error text names wait-online, since any non-zero exit (not only the timeout) reaches it. test_installer_contract.py asserts the wrapper has no `command -v` guard, calls the absolute path exactly once with --any, --ipv4 and a --timeout=, inside the inst.ddi_url block and before the curl download, and that the build-time check is present. Assisted-by: Claude Fable 5.1 via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- elements/oci/bluefin-server-installer.bst | 28 +++++++++++++++----- tests/unit/test_installer_contract.py | 32 +++++++++++++++++++++++ 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/elements/oci/bluefin-server-installer.bst b/elements/oci/bluefin-server-installer.bst index 2232d543..eabbd31f 100644 --- a/elements/oci/bluefin-server-installer.bst +++ b/elements/oci/bluefin-server-installer.bst @@ -80,6 +80,12 @@ config: exit 1 fi done + # bluefin-sysinstall calls this by absolute path (it is not on PATH), so + # pin the location here rather than discover a move at install time. + if ! [ -x /layer/usr/lib/systemd/systemd-networkd-wait-online ]; then + echo "ERROR: /usr/lib/systemd/systemd-networkd-wait-online is missing from the staged rootfs at /layer!" >&2 + exit 1 + fi # systemd-native initrd: /init -> PID 1 ln -sf usr/lib/systemd/systemd /layer/init @@ -260,12 +266,22 @@ config: } mkdir -p /dev/shm/installer echo "==> Fetching DDI from ${DDI_URL}..." - if command -v systemd-networkd-wait-online >/dev/null 2>&1; then - systemd-networkd-wait-online --timeout=90 || { - echo "ERROR: network did not come up before the DDI download timeout." >&2 - exit 1 - } - fi + # The binary lives in /usr/lib/systemd, not on PATH: a `command -v` + # guard silently skipped the wait and curl raced the DHCP lease. It is + # called from here, not via systemd-networkd-wait-online.service, so + # the wait stays conditional on inst.ddi_url (offline USB installs + # must not wait) and a failure aborts the install. + # --any: the installer's 80-dhcp.network matches every en*/eth* + # interface, and without --any an unplugged NIC (no-carrier, setup + # state "configuring") would hold the wait until the timeout. + # --ipv4: a link counts as configured once any one dynamic protocol + # finished, so on a LAN with router advertisements (SLAAC/DHCPv6) the + # wait would return before the DHCPv4 lease; the download needs an + # IPv4 address on the link that satisfies the wait. + /usr/lib/systemd/systemd-networkd-wait-online --any --ipv4 --timeout=90 || { + echo "ERROR: systemd-networkd-wait-online failed: no interface got an IPv4 address within 90 s (or wait-online itself failed, see above)." >&2 + exit 1 + } curl --fail --silent --show-error --location --retry 3 \ --output /dev/shm/installer/bluefin-server-ddi.raw.zst "${DDI_URL}" printf '%s %s\n' "${DDI_SHA256}" /dev/shm/installer/bluefin-server-ddi.raw.zst \ diff --git a/tests/unit/test_installer_contract.py b/tests/unit/test_installer_contract.py index 791ca6e8..605f41d7 100644 --- a/tests/unit/test_installer_contract.py +++ b/tests/unit/test_installer_contract.py @@ -393,6 +393,38 @@ def test_installer_space_preflight_falls_back_to_five_times_compressed( assert "need ~5 MiB; tmpfs has 4 MiB free" in short.stderr +def test_installer_network_ddi_waits_for_networkd_by_absolute_path(installer_wrapper: str) -> None: + installer_element = INSTALLER_ELEMENT.read_text(encoding="utf-8") + wrapper = installer_wrapper + + # systemd-networkd-wait-online lives in /usr/lib/systemd, not on PATH, so a + # `command -v` guard never fired and curl raced the DHCP lease. --any keeps + # an unplugged second NIC (matched by 80-dhcp.network, stuck in + # "configuring") from holding the wait until the timeout; --ipv4 keeps a + # SLAAC/DHCPv6-configured link from satisfying the wait before the DHCPv4 + # lease the download needs. + assert "command -v systemd-networkd-wait-online" not in wrapper + assert wrapper.count("/usr/lib/systemd/systemd-networkd-wait-online") == 1 + call = re.search( + r"^\s*/usr/lib/systemd/systemd-networkd-wait-online\b(?P[^|\n]*)\|\|", wrapper, re.MULTILINE + ) + assert call, "the wrapper must call systemd-networkd-wait-online by absolute path with a failure handler" + args = call.group("args").split() + assert "--any" in args + assert "--ipv4" in args + assert any(arg.startswith("--timeout=") for arg in args) + + # The wait must sit inside the inst.ddi_url block (an unconditional wait + # would stall every offline USB install) and before the download. + ddi_block = wrapper.index('if [ -n "${DDI_URL}" ]; then') + fetch = wrapper.index('--output /dev/shm/installer/bluefin-server-ddi.raw.zst "${DDI_URL}"') + assert ddi_block < call.start() < fetch + assert "ERROR: systemd-networkd-wait-online failed" in wrapper + + # The build fails if the FSDK ever moves the binary out from under the path. + assert "if ! [ -x /layer/usr/lib/systemd/systemd-networkd-wait-online ]; then" in installer_element + + def test_interactive_installer_uses_local_virtual_console() -> None: installer_element = INSTALLER_ELEMENT.read_text(encoding="utf-8")