diff --git a/Justfile b/Justfile index c3cf9bb3..788423f4 100644 --- a/Justfile +++ b/Justfile @@ -466,7 +466,7 @@ test-installer-artifact: Type=oneshot TimeoutStartSec=infinity StandardOutput=journal+console - ExecStart=/usr/bin/bash -c 'echo "<4>kiosk-ready: polling https://127.0.0.1:8080"; i=0; until [ "$(curl --silent --fail --insecure --max-time 2 https://127.0.0.1:8080/healthz | jq -r .status)" = ok ] && [ "$(curl --silent --fail --insecure --max-time 2 --output /dev/null --write-out "%%{http_code}" https://127.0.0.1:8080/)" = 200 ]; do i=$((i+1)); if [ $((i %% 15)) -eq 0 ]; then echo "<4>kiosk-ready: waiting k0s=$(systemctl is-active k0scontroller.service) hz=$(curl -sk -o /dev/null -w "%%{http_code}" --max-time 2 https://127.0.0.1:8080/healthz) root=$(curl -sk -o /dev/null -w "%%{http_code}" --max-time 2 https://127.0.0.1:8080/) pods=$(k0s kubectl get pods -A --no-headers 2>/dev/null | wc -l) running=$(k0s kubectl get pods -A --no-headers 2>/dev/null | grep -c Running)"; fi; sleep 2; done; echo "<4>KIOSK_CONSOLE_READY"' + ExecStart=/usr/bin/bash -c 'echo "<4>kiosk-ready: polling https://127.0.0.1:8080"; i=0; until [ "$(curl --silent --fail --insecure --max-time 2 https://127.0.0.1:8080/healthz | jq -r .status)" = ok ] && [ "$(curl --silent --fail --insecure --max-time 2 --output /dev/null --write-out "%%{http_code}" https://127.0.0.1:8080/)" = 200 ]; do i=$((i+1)); if [ $((i %% 15)) -eq 0 ]; then echo "<4>kiosk-ready: waiting k0s=$(systemctl is-active k0scontroller.service) hz=$(curl -sk -o /dev/null -w "%%{http_code}" --max-time 2 https://127.0.0.1:8080/healthz) root=$(curl -sk -o /dev/null -w "%%{http_code}" --max-time 2 https://127.0.0.1:8080/) pods=$(k0s kubectl get pods -A --no-headers 2>/dev/null | wc -l) running=$(k0s kubectl get pods -A --no-headers 2>/dev/null | grep -c Running)"; k0s kubectl get pods -A --no-headers 2>/dev/null | sed "s/^/<4>kiosk-pods: /"; k0s kubectl get nodes -o wide --no-headers 2>/dev/null | sed "s/^/<4>kiosk-node: /"; k0s kubectl get events -A --no-headers 2>/dev/null | grep -v FailedScheduling | tail -n 8 | sed "s/^/<4>kiosk-events: /"; journalctl -u k0scontroller --no-pager -n 800 2>/dev/null | grep -iE "error|fail|taint" | grep -vE "FailedScheduling|apply.*retrying" | tail -n 8 | sed "s/^/<4>kiosk-k0s: /"; fi; sleep 2; done; echo "<4>KIOSK_CONSOLE_READY"' UNIT ) diff --git a/elements/bluefin-server/os-resolv-conf.bst b/elements/bluefin-server/os-resolv-conf.bst new file mode 100644 index 00000000..79361cc1 --- /dev/null +++ b/elements/bluefin-server/os-resolv-conf.bst @@ -0,0 +1,14 @@ +kind: import +description: | + Install the tmpfiles.d rule that recreates Flatcar's /etc/resolv.conf + symlink to systemd-resolved's resolv.conf. The Flatcar /usr payload does + not carry it (Flatcar ships the symlink in the image /etc, which this DDI + does not import), and kubelet requires /etc/resolv.conf to create any pod + sandbox. + +sources: + - kind: local + path: files/os/tmpfiles.d + +config: + target: /usr/lib/tmpfiles.d diff --git a/elements/bluefin-server/os-stack.bst b/elements/bluefin-server/os-stack.bst index 44f80576..5aa65158 100644 --- a/elements/bluefin-server/os-stack.bst +++ b/elements/bluefin-server/os-stack.bst @@ -44,6 +44,9 @@ depends: # Wired DHCP configuration for the installed OS - bluefin-server/os-networkd.bst + # /etc/resolv.conf symlink to systemd-resolved (tmpfiles.d) + - bluefin-server/os-resolv-conf.bst + # Activate the optional k0s sysext after installation - bluefin-server/os-k0s-first-boot.bst diff --git a/files/os/systemd/system-preset/zz-enable-bluefin-firstboot-credentials.preset b/files/os/systemd/system-preset/20-bluefin-firstboot-credentials.preset similarity index 100% rename from files/os/systemd/system-preset/zz-enable-bluefin-firstboot-credentials.preset rename to files/os/systemd/system-preset/20-bluefin-firstboot-credentials.preset diff --git a/files/os/systemd/system-preset/zz-enable-k0s-first-boot.preset b/files/os/systemd/system-preset/20-bluefin-k0s-first-boot.preset similarity index 100% rename from files/os/systemd/system-preset/zz-enable-k0s-first-boot.preset rename to files/os/systemd/system-preset/20-bluefin-k0s-first-boot.preset diff --git a/files/os/systemd/system-preset/zz-enable-networkd.preset b/files/os/systemd/system-preset/20-bluefin-networkd.preset similarity index 100% rename from files/os/systemd/system-preset/zz-enable-networkd.preset rename to files/os/systemd/system-preset/20-bluefin-networkd.preset diff --git a/files/os/systemd/system-preset/zz-enable-sshd.preset b/files/os/systemd/system-preset/20-bluefin-sshd.preset similarity index 100% rename from files/os/systemd/system-preset/zz-enable-sshd.preset rename to files/os/systemd/system-preset/20-bluefin-sshd.preset diff --git a/files/os/systemd/system-preset/zz-enable-systemd-network-generator.preset b/files/os/systemd/system-preset/20-bluefin-systemd-network-generator.preset similarity index 100% rename from files/os/systemd/system-preset/zz-enable-systemd-network-generator.preset rename to files/os/systemd/system-preset/20-bluefin-systemd-network-generator.preset diff --git a/files/os/systemd/system-preset/zz-enable-var-mount.preset b/files/os/systemd/system-preset/20-bluefin-var-mount.preset similarity index 100% rename from files/os/systemd/system-preset/zz-enable-var-mount.preset rename to files/os/systemd/system-preset/20-bluefin-var-mount.preset diff --git a/files/os/tmpfiles.d/20-bluefin-resolv.conf b/files/os/tmpfiles.d/20-bluefin-resolv.conf new file mode 100644 index 00000000..085ac2ab --- /dev/null +++ b/files/os/tmpfiles.d/20-bluefin-resolv.conf @@ -0,0 +1,11 @@ +# Flatcar's image build populates /etc/resolv.conf in the image's /etc and +# strips /etc-populating lines from /usr/lib/tmpfiles.d (see +# flatcar/scripts build_library/build_image_util.sh). This DDI imports only +# Flatcar's /usr and boots with an empty /etc, so nothing ever creates the +# symlink and kubelet fails every pod sandbox with +# "open /etc/resolv.conf: no such file or directory". +# +# Recreate Flatcar's stock symlink: /etc/resolv.conf points at +# systemd-resolved's full resolver list (not the 127.0.0.53 stub), matching +# Flatcar >= 3510.3.0 behaviour. +L /etc/resolv.conf - - - - ../run/systemd/resolve/resolv.conf diff --git a/tests/unit/test_credentials_provisioning.py b/tests/unit/test_credentials_provisioning.py index f9c36654..852207e1 100644 --- a/tests/unit/test_credentials_provisioning.py +++ b/tests/unit/test_credentials_provisioning.py @@ -24,7 +24,7 @@ / "os" / "systemd" / "system-preset" - / "zz-enable-bluefin-firstboot-credentials.preset" + / "20-bluefin-firstboot-credentials.preset" ) NETWORK_GENERATOR_PRESET = ( REPO_ROOT @@ -32,7 +32,7 @@ / "os" / "systemd" / "system-preset" - / "zz-enable-systemd-network-generator.preset" + / "20-bluefin-systemd-network-generator.preset" ) NETWORK_GENERATOR_DROPIN = ( REPO_ROOT diff --git a/tests/unit/test_k0s_first_boot.py b/tests/unit/test_k0s_first_boot.py index a185a611..1f89861e 100644 --- a/tests/unit/test_k0s_first_boot.py +++ b/tests/unit/test_k0s_first_boot.py @@ -20,7 +20,7 @@ / "os" / "systemd" / "system-preset" - / "zz-enable-k0s-first-boot.preset" + / "20-bluefin-k0s-first-boot.preset" ) NETWORK = ROOT / "files" / "os" / "systemd" / "network" / "20-wired.network" NETWORK_PRESET = ( @@ -29,7 +29,7 @@ / "os" / "systemd" / "system-preset" - / "zz-enable-networkd.preset" + / "20-bluefin-networkd.preset" ) ELEMENT = ROOT / "elements" / "bluefin-server" / "os-k0s-first-boot.bst" NETWORK_ELEMENT = ROOT / "elements" / "bluefin-server" / "os-networkd.bst" @@ -146,3 +146,49 @@ def test_k0s_sysupdate_transfer_is_packaged_as_a_component() -> None: "bluefin-server/os-k0s-sysupdate.bst" in STACK.read_text(encoding="utf-8") ) + + +def test_presets_sort_before_flatcar_disable_all() -> None: + # Flatcar's /usr ships /usr/lib/systemd/system-preset/99-default.preset + # containing a catch-all "disable *". systemd applies preset files in + # lexicographic filename order and the first matching line wins, so any + # Bluefin preset named after 99-default.preset is silently ignored at + # first-boot preset-all. + preset_dir = PRESET.parent + presets = sorted(p.name for p in preset_dir.glob("*.preset")) + assert presets, f"no presets found in {preset_dir}" + for name in presets: + assert name < "99-default.preset", ( + f"{name} sorts after Flatcar's 99-default.preset; its " + "'disable *' catch-all would win and the preset would be ignored" + ) + + +def test_etc_resolv_conf_symlink_is_seeded_for_kubelet() -> None: + # Flatcar ships /etc/resolv.conf inside the image /etc and strips + # /etc-populating lines from /usr/lib/tmpfiles.d at image build. This DDI + # imports only Flatcar's /usr and first-boots with an empty /etc, so + # without an explicit tmpfiles.d rule the symlink never exists and + # kubelet fails every pod sandbox with + # "open /etc/resolv.conf: no such file or directory". + conf = ( + ROOT / "files" / "os" / "tmpfiles.d" / "20-bluefin-resolv.conf" + ) + assert conf.is_file(), "resolv.conf tmpfiles rule is missing" + lines = [ + line + for line in conf.read_text(encoding="utf-8").splitlines() + if line and not line.startswith("#") + ] + assert lines == [ + "L /etc/resolv.conf - - - - ../run/systemd/resolve/resolv.conf" + ] + + element = ( + ROOT / "elements" / "bluefin-server" / "os-resolv-conf.bst" + ).read_text(encoding="utf-8") + assert "path: files/os/tmpfiles.d" in element + assert "target: /usr/lib/tmpfiles.d" in element + assert ( + "bluefin-server/os-resolv-conf.bst" in STACK.read_text(encoding="utf-8") + )