Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
14 changes: 14 additions & 0 deletions elements/bluefin-server/os-resolv-conf.bst
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions elements/bluefin-server/os-stack.bst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions files/os/tmpfiles.d/20-bluefin-resolv.conf
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions tests/unit/test_credentials_provisioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
/ "os"
/ "systemd"
/ "system-preset"
/ "zz-enable-bluefin-firstboot-credentials.preset"
/ "20-bluefin-firstboot-credentials.preset"
)
NETWORK_GENERATOR_PRESET = (
REPO_ROOT
/ "files"
/ "os"
/ "systemd"
/ "system-preset"
/ "zz-enable-systemd-network-generator.preset"
/ "20-bluefin-systemd-network-generator.preset"
)
NETWORK_GENERATOR_DROPIN = (
REPO_ROOT
Expand Down
50 changes: 48 additions & 2 deletions tests/unit/test_k0s_first_boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand All @@ -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"
Expand Down Expand Up @@ -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")
)