Skip to content

fix(cli): delete honors --kubeconfig/--context; clears active-client pointer under --keep-data - #165

Merged
saadqbal merged 1 commit into
developfrom
fix/delete-bugbot-kubeconfig-keepdata
Jul 7, 2026
Merged

fix(cli): delete honors --kubeconfig/--context; clears active-client pointer under --keep-data#165
saadqbal merged 1 commit into
developfrom
fix/delete-bugbot-kubeconfig-keepdata

Conversation

@saadqbal

@saadqbalsaadqbal commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Resolves both Cursor Bugbot findings on the develop→main PR #164.

High — delete ignored --kubeconfig/--context

tracebloc delete registered --kubeconfig/--context but runDelete never read them, so helm uninstall ran against the ambient current-context. An operator whose current context isn't the local tracebloc cluster could uninstall the wrong release.

  • nodeboot.UninstallChart now takes kubeconfig + kubeContext and appends --kubeconfig / --kube-context to the helm call (only when non-empty, so default-context behavior is unchanged).
  • runDelete threads o.kubeconfigPath / o.contextOverride through.
  • k3d cluster delete targets the cluster by name, so it's context-independent — no change needed there.

Medium — --keep-data left a dangling active-client pointer

Under --keep-data, offboard revoked the credential but left the active-client pointer in ~/.tracebloc, so a later sign-in / reinstall still treated the host as enrolled as the (now-revoked) client.

  • Clear ActiveClientID/Name/Namespace even under --keep-data; the token and on-host datasets stay, and re-running client create re-adopts by cluster_id (§7.5 principle: a dead credential must not leave a live-looking pointer).

Tests

  • unit: --kubeconfig/--kube-context appear in the helm args.
  • delete-level: the flags reach the uninstall seam; --keep-data clears the pointer while sparing the data dir.
  • go build/vet/test ./... green (11 pkgs).

Once merged to develop, #164 (develop→main) picks these up. Rolls up under the §7.10 offboarding work (no separate ticket — Bugbot follow-up).

🤖 Generated with Claude Code


Note

Medium Risk
Changes offboarding teardown (Helm cluster selection) and local enrollment state after revoke; mistakes could uninstall the wrong release or confuse reinstall, but scope is limited to the delete path with new tests.

Overview
Helm uninstall targetingrunDelete forwards --kubeconfig and --context into nodeboot.UninstallChart, which adds --kubeconfig / --kube-context to helm uninstall when set so offboard hits the intended cluster instead of the ambient current-context.

--keep-data enrollment state — After revoke, offboard still clears ActiveClientID, ActiveClientName, and ActiveClientNamespace in config and saves, while leaving ~/.tracebloc on disk so later client create can re-adopt without the host looking still enrolled.

Tests cover Helm args, delete-level flag threading, and active-client clearing under --keep-data.

Reviewed by Cursor Bugbot for commit 6ced546. Bugbot is set up for automated code reviews on this repo. Configure here.

…inter under --keep-data
Two Cursor Bugbot findings on the develop->main PR (#164):
- High: `tracebloc delete` registered --kubeconfig/--context but runDelete
never read them, so `helm uninstall` ran against the ambient
current-context — offboarding could uninstall the wrong release when the
operator's context isn't the tracebloc cluster. UninstallChart now takes
kubeconfig + kubeContext and appends --kubeconfig/--kube-context (only
when set, preserving default-context behavior); runDelete threads the
flags through. (k3d cluster delete targets the cluster by name, so it's
context-independent.)
- Medium: under --keep-data, offboard revoked the credential but left the
active-client pointer in ~/.tracebloc, so a later sign-in/reinstall still
saw the host as enrolled as the (now-revoked) client. Clear
ActiveClientID/Name/Namespace even under --keep-data (token + on-host data
stay; re-running `client create` re-adopts by cluster_id), per §7.5.
Tests: flags reach helm (unit + delete-level); --keep-data clears the
pointer while sparing the data dir. go build/vet/test green (11 pkgs).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@saadqbalsaadqbal self-assigned this Jul 7, 2026
@saadqbal
saadqbal merged commit 3a77a85 into developJul 7, 2026
20 checks passed
saadqbal added a commit that referenced this pull request Jul 8, 2026
…atch phase)
Four low/medium follow-ups from the Bugbot review of PR #164; the other
five Bugbot items were already fixed by #165/#168/#171.
- delete: fail fast on a 401/403 from the pre-offboard online check
(revoked/expired credential) with a `tracebloc login` hint, instead of
warning and marching the user through the confirm only to fail at revoke.
- delete: clear + persist the active-client pointer IMMEDIATELY after the
revoke succeeds (before the best-effort teardown), so a failed or
interrupted teardown can't leave the host looking enrolled under a dead
credential.
- delete: mark the offboard degraded when removeSelf can't remove the CLI
binary / own `tb` alias, so the closing line stops claiming a clean
offboard while the CLI is still on disk.
- data ingest: a pod already in Succeeded prints "Ingestion complete —
showing its logs:" (replayed) instead of the "live progress:" line.
Tests added for each; full internal/... suite + go vet + gofmt green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@saadqbal
saadqbal deleted the fix/delete-bugbot-kubeconfig-keepdata branch July 10, 2026 10:37
Sign up for freeto 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.

4 participants

@saadqbal@divyasinghds@aptracebloc@LukasWodka