Skip to content

feat(serve): remove a destroyed host's tailnet device and rename it with the host - #72

Merged
helightdev merged 1 commit into
mainfrom
tailnet-device-lifecycle
Nov 15, 2026
Merged

helightdev merged 1 commit into
mainfrom
tailnet-device-lifecycle

Conversation

@helightdev

Copy link
Copy Markdown
Owner

berth now removes a host's device from the tailnet when it destroys the host's machine. When a host is renamed with --hostname, berth renames the device too.

  • Each apply records the device in the store under a new tailnet kind, next to access: its stable id (Tailscale's nodeId, or Headscale's node number), MagicDNS name and addresses. The role reads them from tailscale status --json into applied.json, and berth reads that back through berthd at the end of the apply. Rename moves the record, forget drops it, and a duplicate starts without one.
  • remove destroy=yes deletes the device once the provisioner has destroyed the machine. A missing key, a refused key or a device that is already gone is reported in the job. The host is forgotten anyway. Removing without destroy leaves the device alone.
  • A rename with hostname=yes marks the device to be renamed. The next apply does the rename, after the machine has taken the new hostname. That way berth can still reach the host by its old MagicDNS name for that apply, and the name on the tailnet changes at the same time as the machine's. If the profile's address is the old name, berth changes it to the new one. A rename that is refused waits for the next apply.
  • A host with no record yet (set up before this change) is looked up in the device list, first by its address and then by its hostname. berth acts only when exactly one device matches.

The scopes are checked against Tailscale's API docs. Deleting and renaming need devices:core. Listing needs devices:core:read, which devices:core includes. Making keys still needs auth_keys. Headscale API keys have no scopes. The access page and the refusal messages say this.

Everything was tested against fake Tailscale and Headscale servers and a local berthd, never against a real control server.

@helightdev
helightdev merged commit a3c8227 into main Nov 15, 2026
23 checks passed
@helightdev
helightdev deleted the tailnet-device-lifecycle branch November 15, 2026 23:36
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.

1 participant