feat(#131): R7 — adopt-and-backfill the live in-cluster client instead of minting an orphan#132
Merged
Merged
Conversation
…n't mint an orphan On an existing-fleet box a live tracebloc client whose backend cluster_id is still null (installed before the anchor shipped) was re-provisioned by `client create` as a fresh mint: the freshly-read kube-system UID matched no client, so the backend minted a new one and stamped the anchor on it, stranding the live client. This is the RFC-0001 §7.2 / R7 case the create flow explicitly deferred; it's the root cause behind the installer band-aid in tracebloc/client#303 (PR #305). The backend already ships everything (backend#883/#893): cluster_id get-or-create and a PATCH adopt-backfill. This wires the CLI half: - api: PatchClientClusterID → PATCH /edge-device/{id}/ {cluster_id}; 409/403 surface as typed APIError. - cluster: DiscoverInClusterClient(ID) reads the live CLIENT_ID from the chart's <release>-secrets Secret, located by the chart labels in the jobs-manager namespace (best-effort, time-bounded like ClusterID). - client create: before minting, if a client is live on this cluster and the anchor is readable, confirm the signed-in account owns it (by UUID username), PATCH-backfill the anchor onto it, and adopt it — no mint. A live client not in the account is refused (cross-account, R6); ownership that can't be verified (list failed) fails closed rather than mint over it. Fresh machines and already-anchored re-runs are unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
👋 Heads-up — Code review queue is at 34 / 30 Above the WIP limit. The team convention is to review existing PRs before opening new work. Open PRs currently in Code review (oldest first):
Pull from review before opening new work. (This is a nudge from the kanban WIP check, not a block.) |
aptracebloc
approved these changes
Jul 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #131.
The proper fix for the orphaned-mint bug (the band-aid was tracebloc/client#303 / PR #305). On an existing-fleet box, a live client whose backend
cluster_idis null (installed before the anchor shipped) was re-provisioned as a fresh mint — the kube-system UID matched nothing, so the backend minted a new client and stranded the live one.Backend already ships the whole contract (backend#883/#893, merged to master
ee247ee4):cluster_idget-or-create +PATCH /edge-device/{id}/adopt-backfill. This is the CLI half:PatchClientClusterID→PATCH /edge-device/{id}/ {cluster_id}; 409/403 → typedAPIError.DiscoverInClusterClientreads the liveCLIENT_IDfrom the chart's<release>-secretsSecret (located by chart labels in the jobs-manager namespace; best-effort, time-bounded likeClusterID).Fresh machines and already-anchored re-runs are unchanged.
Follow-ups (separate):
Tests:
PatchClientClusterID(200 + 409);DiscoverInClusterClientID(happy / no-release / release-without-secret, incl. ignoring the node-agents mirror); create-flow R7 (adopt-backfill, already-anchored, cross-account refuse).🤖 Generated with Claude Code
Note
Medium Risk
Changes core client provisioning and identity binding; mistakes could mint duplicates or mishandle cross-account clusters, though the new path is fail-closed and covered by targeted tests.
Overview
Fixes orphaned mint on legacy fleets: when a tracebloc client is already running but the backend
cluster_idis empty,tracebloc client createnow adopts that client instead of POSTing a duplicate.API adds authenticated PATCH (
bodyRequestshared with POST) andPatchClientClusterIDto stampcluster_idon/edge-device/{id}/, with 409/403 as typedAPIErrors.Cluster adds
DiscoverInClusterClient: find the jobs-manager namespace via chart labels, readCLIENT_IDfrom the release secrets (ignoring node-agents mirrors).client createruns R7 before mint: discover live client, fail closed if a client is live but account list fails, refuse cross-account adopt, PATCH backfill when anchor is null, or adopt when already anchored; only then fall through to the existing mint/get-or-create path. Adopt output still usesTRACEBLOC_CLIENT_ADOPTEDand no new password.Reviewed by Cursor Bugbot for commit 73d6155. Bugbot is set up for automated code reviews on this repo. Configure here.