Skip to content

feat(controller): bind sandbox namespaces to workspace and instance ownership - #548

Draft
Pal Lakatos-Toth (pallakatos) wants to merge 4 commits into
public/pr4-inferencefrom
public/pr5-namespace-ownership
Draft

feat(controller): bind sandbox namespaces to workspace and instance ownership#548
Pal Lakatos-Toth (pallakatos) wants to merge 4 commits into
public/pr4-inferencefrom
public/pr5-namespace-ownership

Conversation

@pallakatos

@pallakatos Pal Lakatos-Toth (pallakatos) commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Publication stack

Follows #543 -> #544 -> #545 -> #547. This draft targets the inference branch so the diff contains only namespace ownership and its directly coupled creation/cleanup paths. Do not merge into the intermediate feature branch. After its parent lands, retarget to the protected kars-bridge integration branch and require fresh exact-head CI and independent approval. Main promotion remains a separate final gate.

Scope

  • Bind runtime namespaces to the exact source workspace, Sandbox name/UID and Namespace UID backlink; guard reconciliation, cleanup, approval targets and router-token reads.
  • Create new namespaces atomically. Reject cross-workspace same-name collisions, recreated identities and unproven existing namespaces without force adoption.
  • Preserve proven legacy workloads through metadata-only adoption; add read-only kars namespace preflight and explicit reviewed-UID administrator adoption for ambiguous cases.
  • Preflight both upgrade commands and SRE installation against an existing controller. Discovery/RBAC/transport errors never become false absence or a forced reinstall.
  • Preserve kars add and local-Kubernetes kars dev credential prestaging through a two-way reservation. Fresh SRE installs let the controller claim the namespace before creating the writer account; real Helm upgrades retain exact-release legacy resources.
  • Fence the existing handoff credential writer by created Sandbox identity, live namespace claim/backlink, metadata-only Secret anchor and Secret UID/resourceVersion. No new credential sources or RBAC expansion.
  • Handle legacy self-hosted namespace GC without adopting unproven resources, and preserve normal cancellation when deletion races reservation binding.

This is a safety prerequisite, not generic credential sources, durable aggregate budgets, complete Team execution, or Bridge publication. Kars still has no dependency on Bridge. No live cluster migration, customer deployment, image publication, release or main merge is performed by this PR.

Compatibility and migration

Read docs/how-to/namespace-ownership.md before controller replacement. Proven legacy namespaces keep their UID, data and pod templates. Same-second/ambiguous ownership requires an explicit administrator decision; conflicts leave running resources untouched rather than silently adopting them. Old unfinished pre-CR reservations require separate inventory. Direct Helm/GitOps upgrades must run preflight; client-only rendering cannot infer previous Helm ownership, so pruning workflows must preserve migrated legacy runtime namespaces. Rolling back to an older controller removes claim-v1 enforcement.

Evidence and open gates

Candidate: 62093414cb8d5d9937c1d9974504047c84669d6c, based on inference head 45cfa009.

  • Local repair qualification: 42 focused controller tests, 32 spawn tests including 11 credential-claim regressions, and 161 CLI/Helm/dev tests passed. Strict all-target Clippy for both crates, typecheck/scoped lint and existing static gates passed.
  • Actual Helm lookup is exercised against an isolated read-only test API, including legacy retention, disabled SRE, foreign releases, absence and read failures.
  • The disposable Kind gate passed at this exact head: 105 cases, zero failures, including actual SRE install with UID-bound namespace/writer materialization and removal preserving the core namespace. Evidence: https://github.com/Azure/kars/actions/runs/34150756641/job/101838058446 . No live customer cluster was used.
  • Hosted exact-head CLI/Rust/Helm, dependency/security, CodeQL, Kind, chaos and benchmark checks have all passed. This supplies the lockfile-exact evidence missing from the earlier authorized local cache runs. The sole remaining failing check is security-audit-required: zero genuine Signed-off-by entries are present and two are required (author plus independent reviewer).
  • Automated technical review has closed all reported namespace findings at 62093414, including handoff credential fencing and reservation cancellation; no significant regressions were found in those bounded paths. This was source-level review and regression inspection, not independent execution, live-cluster qualification or human approval. Genuine review/sign-offs and the full CI gates remain required.
  • The dated capability audit is docs/security-audits/2026-09-07-sandbox-namespace-ownership.md. Genuine author and independent reviewer sign-offs are pending. The audit gate must remain blocked until those sign-offs exist; no identity or approval is fabricated.

Keep this PR draft until its remaining review and CI gates are satisfied.

Add atomic namespace claims, conservative legacy adoption, preconditioned cleanup, and workspace-aware guards for approval cleanup and router token reads. Preserve pre-CR credential staging through explicit namespace reservations, and preflight both upgrade paths before changing controllers.

Validation: 107 focused CLI/Helm tests, TypeScript typecheck, changed-file lint, and Rust formatting pass. The 26 focused Rust tests await the coordinated shared Cargo slot; no Rust build or target directory was created.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: eb3654cd-f1e0-445a-8734-430800af1903
Keep the prestage fixture initializer compliant with strict Clippy. Qualified the actual namespace adoption, preservation, collision, UID recreation, CAS retry, and cleanup cases: all 107 affected controller tests pass, including 26 namespace ownership tests. Controller all-targets Clippy passes with warnings denied, using only the shared Cargo target and CARGO_INCREMENTAL=0.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: eb3654cd-f1e0-445a-8734-430800af1903
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: eb3654cd-f1e0-445a-8734-430800af1903
…dentials

Complete the dev/SRE namespace producer migration, retain legacy Helm resources, preserve cancellation during claim binding, and fence existing handoff credential writes by the created sandbox and Secret identities. Keep genuine audit sign-offs and final independent closure pending.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: eb3654cd-f1e0-445a-8734-430800af1903
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

}))
}

fn metadata_response(object: &Value) -> ResponseTemplate {
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.

2 participants