Skip to content

devcloud 0.8.0: a host's tailnet node kind follows its lease (board #115) - #337

Merged
SSFSKIM merged 15 commits into
mainfrom
devcloud-lease-rejoin
Oct 22, 2026
Merged

SSFSKIM merged 15 commits into
mainfrom
devcloud-lease-rejoin

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Board #115 (api board; no closing keyword): a devcloud host's tailnet node kind now follows its lease at every change, not only at its first join. The node is ephemeral while the host is leased and non-ephemeral while it is kept, and it keeps the host's name either way. devcloud 0.7.0 → 0.8.0.

What the measurement changed. The ticket's open question, measured first on a throwaway VM: tailscale logout does not remove a non-ephemeral tagged node. The node stays listed, expired, under its name, and the next join gets <name>-1. A node's kind cannot change in place either; even --force-reauth makes a new node. So a rejoin has to remove the old node through the Tailscale API. That needs devices:core, and the person chose that option knowing its reach. The main session replaced the hosts' OAuth client: version 2 of the same secret now carries auth_keys + devices:core on tag:devcloud only. The old client, which also held policy_file, dns and users, is revoked.

What changed

  • Host. The join records the kind it asked for (/var/lib/devcloud/tailnet.json). A lease write that leaves the node behind starts devcloud rejoin as the transient unit devcloud-rejoin. The rejoin runs in this order:
    1. Check the token's scope.
    2. Record the old node's id as pending.
    3. Log out.
    4. Remove the old node through the API.
    5. tailscale up as the wanted kind.
      The pending id stays until its removal succeeds, and the node the daemon holds is never removed. The lease service retries a rejoin while the node is behind, on kept hosts too. The boot's tailnet attach converges the same way, and an unreadable status claims no kind. lease set keep removes a lease.
  • Driver. devcloud vm lease <n> keep --confirmed relabels the VM kept, or updates an adoption's record. On a host's rejoin <kind> line the driver waits up to 10 minutes for the host to come back under its name. A complete answer survives the SSH cut the rejoin causes. The reaper relabels kept a VM whose host has no lease.
  • Docs. Driver spec §4.1, §4.3, §6.5, I16, Out of scope, Surprises, the Decision Log (the person's decision and the design choices), Progress and Outcomes. Also the README, the vm skill's lease paragraph, and TECH-DEBT: the SCRATCH drain repro (dp#10) — wontfix on sight #115 entry is removed and four small leftovers are added.

Report: docs/doperpowers/plans/2026-10-22-devcloud-lease-rejoin-report.md.

Validation Evidence

Claim Command Output
Unit tests pass python3 -m unittest discover -s devcloud/tests/unit (at d5e5a2a, the last code commit) Ran 677 tests … OK
keep→lease: ephemeral, same name, ssh works (keep VM, approved) devcloud vm lease dc-kpt-e642 2h; then vm ssh dc-kpt-e642 -- true and the API's device record "is back on the tailnet as an ephemeral node, under the same name" (15 s); ssh exit 0; isEphemeral: true; the record says the old node was removed through the API
lease→keep: needs --confirmed, then non-ephemeral vm lease dc-kpt-e642 keep; then vm lease dc-kpt-e642 keep --confirmed exit 4 "needs the person's yes"; then "back … as a non-ephemeral node, under the same name" (15 s); labels keep, confirmed 1, no expires; ssh exit 0
The same on an adopted machine (approved), released at the lease end with acceptance 7's give-back checks vm adopt … --confirmed (keep), vm lease dc-adp-c8b4 20m, the lease service's release, the checks over a new SSH as the original login, a reset, SSH again rejoined ephemeral (8 s). The release journal: logout ok, 16 credential paths and the ledger removed, released. No ledgered path, hub.json, unit or nft table left; the node left the tailnet; login worked before and after the reset; ls no longer lists it
The review fixes hold on a real host on a throwaway VM, a record faked as non-ephemeral, then systemd-run … devcloud rejoin (on 5321a4e's and d5e5a2a's code) and a hard reset rejoined ephemeral under the same name ("the old node … already gone through the API", nothing pending); the boot after the reset said "already joined", same node id
Every resource deleted the same day gcloud compute instances list, tailscale status no dc- VM and no dc- node left; deletion times in the report
Review clean doperpowers:reviewer-high, three rounds 4 P2 fixed, then 2 P2 fixed, then "correct", no material findings
CI ci-gate GREEN at 275f8fc and 0020899. At 5321a4e, d5e5a2a and f95aeb1 every gate passed (shell-lint, repo-checks, devcloud-mods, devcloud) except mods-types, cancelled three times when its npm exec tsc -p hung until the job's 10-minute limit (e.g. https://github.com/SSFSKIM/doperpowers/actions/runs/39714616472). This diff touches no mods code. Logged in the friction tracker (#304)

Unresolved Review Findings

None from the reviews. The fix wave left four small points open; each is in docs/doperpowers/TECH-DEBT.md under the driver's section, marked board #115:

  • a -1 name kept after a late removal;
  • a refused rejoin retried every 5 minutes without backoff;
  • a Stopped node whose rejoin is refused stays Stopped;
  • two loose messages.

Residue

  • Remove a kept host's node when it leaves for good. A non-ephemeral node stays listed, expired, after a departure's or release's logout (down of a kept VM, the release of a kept adoption). A kept VM deleted while unreachable leaves its node listed with nothing to remove it. Hosts now hold a devices:core client, so the departure could remove its own node after the logout, and the driver could remove the node of a kept VM it deletes without a departure.
  • Desk machine dc-lgt-3d09. The measurement VM was deleted without its leave, so the desk still lists it; the person was asked to remove it by hand.

Sminos-Session: devcloud setup#639ca648 (macbook on macbook)

…p<->lease)

A lease write that changes the kind the node should be (ephemeral while
leased) records the rejoin and starts devcloud-rejoin as a transient unit;
the lease service restarts it while the node is behind, and the boot's
tailnet attach converges the kind too. A non-ephemeral node, which a logout
leaves listed under its name, is removed through the Tailscale API after its
logout, so the new node keeps the name. `lease set keep` and
`devcloud vm lease <n> keep --confirmed` remove a lease; the driver waits
for the host to come back under its name as the new kind.

Sminos-Session: devcloud setup#639ca648 (macbook on macbook)
…ntry gone

The logout measurement, the person's decision and the design choices in the
spec's Surprises and Decision Log; §4.1, §6.5 and I16 describe the rejoin and
`lease <n> keep`; the vm skill names it.

Sminos-Session: devcloud setup#639ca648 (macbook on macbook)
…r the driver

Sminos-Session: devcloud setup#639ca648 (macbook on macbook)
…e end's departure

Sminos-Session: devcloud setup#639ca648 (macbook on macbook)
Sminos-Session: devcloud setup#639ca648 (macbook on macbook)
…th client

Sminos-Session: devcloud setup#639ca648 (macbook on macbook)
The rejoin unit can log the node out right after `lease set` releases the
lock, before SSH delivers its exit status. A lost connection (255, none,
or a signal) whose output holds a rejoin line and then the lease is that
host's answer: the label or record write and the wait follow it. Without
a rejoin line the failure stays.

Sminos-Session: devcloud setup#639ca648 (macbook on macbook)
When `lease keep` removed a host's lease and the label write after it
failed, the VM kept its ttl label and its old lease, and the reaper's
repair read no lease the same as a failed read. host_expires now tells a
descriptor without a lease (KEPT) from a read that failed, and decide
labels such a host kept and confirmed, dropping devcloud-expires: only a
confirmed `up --keep` or `lease keep` leaves a host without a lease.

Sminos-Session: devcloud setup#639ca648 (macbook on macbook)
…lls a held node from none

The old non-ephemeral node's id lived only in a local: a logout that took
effect and then failed or timed out, or a host that stopped before the API
removal, left the next join to find no node and be given <name>-1, the
old node stranded. Its id is now recorded in the kind record (`remove`)
before the logout and cleared once the API removed it or found it gone;
every later OAuth join, at boot or in `devcloud rejoin`, removes a pending
node before its `up`, and a node already of the right kind just has the
removal retried. A removal that still fails joins anyway, keeps the id,
and keeps the node behind so the lease service retries it.

`joined` meant BackendState Running, but a Stopped or Starting backend
still holds its node, which `up --auth-key` resumes as the kind it was
joined as. The join now asks whether tailscaled holds a node (a Self.ID,
or a state other than NeedsLogin, NoState, NeedsMachineAuth): one of the
right kind gets a plain `up`, one behind leaves first. A rejoin whose
status cannot be read is refused, changing nothing; the boot's fresh join
still goes ahead, `up` then failing or joining.

Sminos-Session: devcloud setup#639ca648 (macbook on macbook)
…cannot know

A leave whose logout failed before taking effect left the node held in
`remove`; with the lease turned back, the next join deleted the active
node and recorded it joined. The removal now reads the node held first:
its id is dropped from `remove` without a delete, and nothing is removed
while the status cannot be read. A logout that fails with the same node
still held takes its id back out at once.

A boot whose status could not be read joined as before, but recorded the
wanted kind though `up` may have resumed a node of the other kind. It now
records the kind unknown (and the name only if read), so the node stays
behind and the lease service's rejoin settles it once the status reads.

Sminos-Session: devcloud setup#639ca648 (macbook on macbook)
…nd retrospective; the report's draft

Sminos-Session: devcloud setup#639ca648 (macbook on macbook)
Sminos-Session: devcloud setup#639ca648 (macbook on macbook)
Sminos-Session: devcloud setup#639ca648 (macbook on macbook)
Sminos-Session: devcloud setup#639ca648 (macbook on macbook)
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-22T03:14:15.272123Z f95aeb1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sminos-Session: devcloud setup#639ca648 (macbook on macbook)
@SSFSKIM
SSFSKIM merged commit 53b6587 into main Oct 22, 2026
10 checks passed
@SSFSKIM
SSFSKIM deleted the devcloud-lease-rejoin branch October 22, 2026 03:22
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