Repository navigation
fix(controller): clean retained workspace namespace metadata - #433
Open
Kevin Cho (chokevin) wants to merge 10 commits into
Open
Kevin Cho (chokevin) wants to merge 10 commits into
Kevin Cho (chokevin) wants to merge 10 commits into
Conversation
Pengfei Ni (feiskyer)
requested changes
Oct 20, 2026
Pengfei Ni (feiskyer)
requested changes
Oct 21, 2026
Pengfei Ni (feiskyer)
requested changes
Oct 22, 2026
Pengfei Ni (feiskyer)
requested changes
Oct 22, 2026
Pengfei Ni (feiskyer)
requested changes
Oct 23, 2026
Pengfei Ni (feiskyer)
requested changes
Oct 24, 2026
Pengfei Ni (feiskyer)
requested changes
Oct 24, 2026
| conditions = append(conditions, boolCondition(tauv1alpha1.ConditionDriftDetected, true, "RBACCleanupFailed", err.Error(), workspace.Generation)) | ||
| } | ||
| if previousAccessReady { | ||
| if err := r.cleanupOwnedNamespaceWorkloadIdentity(ctx, workspace, keepServiceAccount); err != nil { |
There was a problem hiding this comment.
When retargeting also changes or removes workloadIdentity, this guard retains the obsolete ServiceAccount while the old namespace RoleBinding is reassigned to the current researcher. With an existing federated identity, that researcher can create new Jobs using the retained account and its previous Azure permissions, despite the identity change in the current spec. An unfinished Workload keeps this access available across reconciles. Separate obsolete-identity revocation from drain retention, or prevent new use of the old account while preserving already-submitted work; cover this combination with a changed researcher subject.
This branch has not been deployed
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.
Summary
Fix workspace finalization and namespace retargeting so retained external queue contracts remain admissible and executable while unfinished Workloads drain. Before deleting workload identity resources, the controller enumerates unfinished Workloads, resolves each surviving LocalQueue and its current or admitted ClusterQueue, verifies recorded ClusterQueue UID continuity when available, and evaluates the live namespace selector against current and post-cleanup labels. If cleanup would break the route, it keeps the namespace metadata and required execution ServiceAccount, and retains the previous resolved target until the Workload finishes.
Researcher authorization is handled independently of that execution-resource drain. During deletion, every workspace-owned researcher RoleBinding is revoked before waiting for unfinished Workloads. During retargeting, a changed researcher subject is applied immediately to the old namespace RoleBinding, and switching to cluster-wide authorization removes the old subject-specific binding. In both paths, the ServiceAccount needed by pending Jobs remains protected until the Workload drains.
Route discovery does not depend on
status.queue, covering legacy deletion after ownership migration with empty queue status and Workloads using supported compatibility aliases. After relevant Workloads finish, finalization or retargeting removes stale RBAC, workload identity, queue resources, and TauGrid namespace metadata as originally intended. Unrelated, out-of-namespace, missing-queue, and selector-independent Workloads do not block cleanup. Queue and selector read failures fail closed, and external LocalQueues and ClusterQueues are never mutated or deleted.The branch includes a normal merge of current
origin/mainat0d5ad5ad; no rebase or force-push was used.Implementation and test drafting used GitHub Copilot; the resulting diff and validation were reviewed before submission.
Related issue
N/A — verified TauGrid v0.4.5 live controller defect found during release validation.
Validation
Validation ran locally on macOS against current
origin/main. No cluster resources were mutated.Compatibility and operational impact
No public API, CLI, CRD, configuration, image, chart, dependency, or security contract changes from this PR. Deleting or retargeting a workspace with unfinished Workloads on a retained external or compatibility queue can remain pending until the Workloads finish or queue/selector evidence becomes readable, including legacy workspaces whose queue status was never populated. During that interval the namespace retains admission routing metadata and the workspace-owned ServiceAccount needed by pending Jobs, while researcher access is revoked on deletion or reconciled to the current authorization during retargeting. Fully drained namespaces still remove stale TauGrid metadata and execution access, and external queues remain untouched.
Checklist