Skip to content

tailscale: keep tailscaled when a rejoin times out at boot - #5

Merged
unlucio merged 1 commit into
Bespok3d:devfrom
olavgm:fix/tailscale-join-offline
Nov 10, 2026
Merged

unlucio merged 1 commit into
Bespok3d:devfrom
olavgm:fix/tailscale-join-offline

Conversation

@olavgm

@olavgm olavgm commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

What this changes

After a reboot, the Tailscale plugin could leave the printer off the tailnet for good. ts-run starts tailscaled, then runs tailscale up --timeout=15s under set -e. At boot the Wi-Fi is often not associated yet, so the join times out, the script exits, its trap stops tailscaled, and the U1's service script never starts it again.

This keeps tailscaled running when that join fails on a printer that has joined before: it holds the saved login in its state file and connects on its own once the network is up. A first join that fails still stops the service, so a rejected key behaves as before.

  • ts-run writes $DATA_DIR/joined after a tailscale up that succeeds. On a later start, a failed join is logged instead of fatal when that marker exists.
  • Tailscale 0.1.3, with changelog and README entries.

Fixes #4.

User story

As a printer owner who reaches the printer over Tailscale, I want it back on the tailnet after every reboot, even when the Wi-Fi is slow to connect, so that I do not have to restart the service by hand.

Checklist

  • Scoped to the story above; no unrelated changes.
  • The repo gate passes green locally (bash scripts/check.sh, 11/11).
  • Ships a regression test that fails on the old behavior and passes on the fix: test 4b in tailscale/tests/run.sh (a printer that joined before starts with no network) fails on dev with "ts-run exited on a failed join although this printer had joined before". Test 3 now also checks that a successful join writes the marker.
  • No em-dash or en-dash anywhere (RULE ZERO); the gate enforces it.
  • Docs updated if this changes behavior, a boundary, or configuration.
  • No real secret, token, key, or LAN address in the diff.

Notes for the reviewer

  • On a printer: my U1 (firmware 2.0.0.205), with a local build of the app carrying this branch. I switched Tailscale to the local 0.1.3, which joined straight away, then rebooted: tailscale0 was up 25 seconds after boot. With 0.1.2, the reboot just before it left no tailscale0 five minutes after boot, with good Wi-Fi.
  • Not verified: the timeout path itself on hardware, which has only run against the fake binaries. I could not read the service log, so I have not seen which path that reboot took.
  • Why a marker and not the state file: the state file can exist from a join that never succeeded (tailscaled stores its machine key there on first start), so its presence does not mean the printer ever joined.
  • Printers already on 0.1.2 have no marker. The upgrade restarts the service with the network up, which writes it.
  • Alternative: retrying tailscale up in a loop. I went with letting tailscaled reconnect on its own, as it does on any Linux host, and kept the 15 second bound on the CLI. Happy to switch if you prefer.
  • manifest.json is bumped to 0.1.3; renumber as you see fit.

🤖 Generated with Claude Code

The service starts at boot, often before the Wi-Fi has associated, so `tailscale up` cannot reach
the control server within its 15 seconds. ts-run then exited, its trap stopped tailscaled, and the
service supervisor never started it again: the printer stayed off the tailnet until the service was
restarted by hand. A printer that has joined before keeps its login in the state file and tailscaled
connects on its own once the network is up, so ts-run now records a successful join and, on a later
start, logs a failed join and keeps tracking tailscaled. A first join that fails still stops the
service.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Olav Gausaker <olav@gausaker.com>
unlucio added a commit that referenced this pull request Nov 10, 2026
tailscale: keep tailscaled when a rejoin times out at boot
@unlucio
unlucio merged commit 10924b1 into Bespok3d:dev Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tailscale: the printer drops off the tailnet after a reboot when the Wi-Fi is slow to connect

2 participants