From b42391c43bd88b2ee4bc6fc844d71701e2277449 Mon Sep 17 00:00:00 2001 From: Flegma Date: Mon, 20 Jul 2026 20:49:45 +0200 Subject: [PATCH] feat: pre-warm tailscale path to k3s server on game node start After a reboot the Tailscale direct path to the k3s server can come up one-way (tx>0, rx0). tailscaled self-reports healthy (BackendState Running, empty Health), so the existing state-check passes while the agent cannot reach the control plane: k3s-agent hangs validating the connection, no pods schedule, and the node shows Offline in the panel. Add a best-effort ExecStartPre that, when K3S_URL is set, runs a bounded tailscale ping to the server before k3s starts, forcing the direct path to establish bidirectionally. The drop-in lands in whichever k3s unit dir the node uses (k3s-agent.service.d on agents) and is a no-op on server nodes with no upstream. Prefixed with - so a failed pre-warm can never block k3s from starting. --- game-node-server-setup.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/game-node-server-setup.sh b/game-node-server-setup.sh index 99ccb5a..113ab2f 100755 --- a/game-node-server-setup.sh +++ b/game-node-server-setup.sh @@ -208,6 +208,22 @@ cat <<-'DROPIN' >/etc/systemd/system/k3s.service.d/tailscale-state-check.conf ExecStartPre=/usr/local/bin/5stack-tailscale-state-check.sh DROPIN +# Pre-warm the Tailscale path to the k3s server on (re)start so a one-way path +# after a reboot cannot leave the node unable to reach the control plane. Lands +# in whichever k3s unit dir this node uses; harmless no-op on server nodes. +PREWARM_DIR=/etc/systemd/system/k3s.service.d +[ -f /etc/systemd/system/k3s-agent.service.env ] && PREWARM_DIR=/etc/systemd/system/k3s-agent.service.d +mkdir -p "$PREWARM_DIR" +rm -f "$PREWARM_DIR/tailscale-prewarm.conf" +cat <<-'DROPIN' >"$PREWARM_DIR/tailscale-prewarm.conf" + [Unit] + After=tailscaled.service + Wants=tailscaled.service + + [Service] + ExecStartPre=-/bin/bash -c '. /etc/systemd/system/k3s-agent.service.env 2>/dev/null || true; H=$(echo "${K3S_URL#*://}" | cut -d: -f1 | cut -d/ -f1); [ -n "$H" ] && echo "[5stack] pre-warming tailscale path to $H" && timeout 15 tailscale ping -c 3 "$H" >/dev/null 2>&1 || true' +DROPIN + cat <<-'UNIT' >/etc/systemd/system/5stack-tailscale-state-check.service [Unit] Description=5stack tailscale state check