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")