Uh oh!
There was an error while loading. Please reload this page.
feat(cli): client create reads the cluster anchor — idempotent get-or-create + 409 (#84) - #102
Merged
Merged
Conversation
…-create + 409 (#84) RFC-0001 §7.2 / backend#883: `client create` now reads the cluster's kube-system UID and sends it as cluster_id, so the backend does get-or-create keyed on it. - Reads the anchor via a new cluster.ClusterID (kube-system namespace UID) behind --kubeconfig/--context flags. Best-effort + never-silent: if the cluster isn't reachable it provisions WITHOUT an anchor (a plain mint) and says so. - api.CreateClient returns adopted (HTTP 200) vs minted (201): an idempotent re-run on the same cluster adopts the existing client (no new credential printed) instead of duplicating; a 409 → a clear "registered to a different account" (cluster_conflict). - Adds api.BackfillClusterID (PATCH /edge-device/<id>/) for the adopt-backfill path (the installer #838 orchestrates the full R7 flow). Scope: anchor + idempotency only. never-show (writing the credential into the cluster secret) and the R7 in-cluster TB_CLIENT_ID backfill orchestration land with the installer reorder (#838); the mint-time credential print stays as the interim. Tests: cluster.clusterIDFrom (fake clientset); api CreateClient mint/adopt/409 + BackfillClusterID; cli create anchor-mint / adopt-idempotent / 409 / no-cluster-warns. go build/vet/test ./... green (Go 1.26). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
saadqbal
left a comment
Collaborator
There was a problem hiding this comment.
Two refinements from review — both small, neither blocking. Details inline.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Two review fixes folded into the create-anchor work (#84): - cluster.ClusterID: cap the best-effort kube-system read with an 8s rest.Config timeout. A kubeconfig pointing at an unreachable API server would otherwise hang the GET for the OS TCP timeout; now `client create` degrades to a non-anchored mint promptly instead of stalling before the review prompt. - cli client create: on an idempotent adopt, print the result before saving the active-client pointer and treat a save failure as a hint (mirroring the mint path), so a config-save error can't bury the "adopted it" message or the recovery hint. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
LukasWodka
commented
Jun 24, 2026
ContributorAuthor
Ready for another look @saadqbal:
Code-complete, 0 unresolved threads; just needs your re-review. |
saadqbal
approved these changes
Jun 24, 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 freeto 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.
What
Revises
tracebloc client createto be idempotent on the cluster anchor (RFC-0001 §7.2, against the backend#883 / Appendix C.3 contract). Re-running on the same cluster now adopts the existing client instead of minting a duplicate.cluster.ClusterIDreturns thekube-systemnamespace UID (the stable per-cluster fingerprint).client createsends it ascluster_id, behind--kubeconfig/--context(kubectl conventions, mirroringcluster info).api.CreateClientreports adopt (HTTP 200) vs mint (201):cluster_conflict, R6); 403 still routes to ask-an-admin.Scope (locked: anchor + idempotency only)
Deferred to the installer reorder (#838), where the installer owns writing the credential into the cluster secret and knows the in-cluster
TB_CLIENT_ID:0600cluster/Helm secret instead of printing it) — the mint-time print stays as the interim.TB_CLIENT_IDwhosecluster_idis null and PATCHing it). The PATCH primitive lands with its caller in #838, not here — so this PR ships no unused/dead API surface.Tests
go build / vet / test ./...green (Go 1.26):cluster.clusterIDFromvia a fake clientset (reads kube-system UID; missing-namespace errors).api.CreateClientmint/adopt (status→adopted) + 409→APIError.clicreate: anchor-mint (assertscluster_idis sent), adopt-idempotency over two runs (both adopt the same id, no credential reprinted, password still sent in the body), 409→friendly message, and no-anchor→full mint + never-silent hint.Reviewer notes
cluster_idanchor — get-or-create + 409 + adopt), currently in review. The CLI sendsstring(ns.UID)(already clean), so it's robust regardless of the backend's input canonicalization.Closes part of #84 (the create revision); list/use/picker + selected-vs-connected remain.
🤖 Generated with Claude Code