Repository navigation
Feat/mpr 202 owned deletion - #291
Conversation
The ClusterRole had no rule for core events; the only grant was in the
leader-election Role, in the operator's own namespace. Every event the
recorders emitted on an AIService or AIPlatform elsewhere was rejected
("events is forbidden"), so InvalidSpec and the other warnings never
appeared. Add create/patch on core events to the generated and the Helm
ClusterRole, and require the rule in the test that keeps them identical.
Verified on fullfeature-dev: no rejected event in a full test run, and the
warnings appear on the AIService with the operator's own ClusterRole.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…omer data (MPR-202) Ownership rule for every object the AgentRuntime feature creates: - created with the AIService as controller, so garbage collection removes it and an interrupted reconcile leaves only owned objects; - an existing object under a feature name that this AIService (by UID) does not control is never adopted, rewritten or deleted: the stage fails with reason OwnershipConflict naming it (common.ClaimOrRefuse). The schema Job's occupied-name case reports the same reason; - a ServiceAccount named in features[].serviceAccountName is customer-managed: used if it exists, created without an owner if not, and an owner reference left by an earlier build is removed; - the operator-generated mTLS Secret <name>-tls gets a non-controller owner reference once cert-manager issues it for this Certificate; a user-named secret is never owned. The shared ServiceAccount and Certificate helpers apply the rule only when asked (RefuseUnowned), so SAIA keeps adopting as before. No finalizer: the unused aiservice-protect/aiplatform-protect cleanup handlers are removed, and an object still carrying one from 2025-08 builds is released at once, so deletion can never be held. The platform prunes a removed feature's AIService only when it controls it by UID. Tests: envtest ownership suite (both profiles, same-named objects, partial install, injected API failure, idempotency), helper and controller tests; 30 mutations caught. Cluster-tested on fullfeature-dev, including checkpoint readback after deletion. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion record (MPR-202) ownership-and-deletion.md: the ownership rule, the operator-owned and customer-managed inventories, what remains after each kind of deletion, how to check a deletion, troubleshooting OwnershipConflict and the upgrade note. mpr-202-validation.md and validation/mpr-202-cluster.txt: criteria, tests and the captured fullfeature-dev runs, including the root cause of the Deployment churn fixed by PR #290 (introduced by 955dd11). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 85da066bd6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if err != nil || ai.Spec.MTLS.SecretName != "" { | ||
| // A Secret the user named stays theirs: it is not removed with the AIService. | ||
| return err |
There was a problem hiding this comment.
Detach the TLS Secret when it becomes explicitly user-named
If a runtime initially leaves mtls.secretName unset, ownIssuedSecret adds an AIService owner reference to <svc>-tls. If the user subsequently sets mtls.secretName to that same Secret to retain or share it, this early return leaves the existing owner reference intact. Deleting the AIService therefore still garbage-collects the now explicitly referenced Secret, contrary to the documented preservation behavior; before this change, the operator did not add that reference. Remove this AIService's owner reference when the Secret becomes explicitly user-named, analogous to the customer-managed ServiceAccount handling.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Codex Review: Didn't find any major issues. 👍
Reviewed commit: 8dfb082690
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…tName (MPR-202) Address PR #291 review: a runtime that started without mtls.secretName gets its operator-generated <svc>-tls Secret claimed with an owner reference. If the user then names that same Secret in mtls.secretName to keep it, the reference stayed, so deleting the AIService still removed the Secret, contrary to the documented rule that a user-named Secret is never removed. The operator now removes its own owner reference (by UID) from a user-named Secret, keeping any other, with an optimistic-lock patch. Envtest reproduces the sequence (claimed, then named, then released and idempotent); 32 mutations caught; 24 packages pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…elease (MPR-202) Section 13 of the fullfeature-dev record: the 6b88171 build claims the operator-generated TLS Secret, releases it within 3 s once mtls.secretName names it, and the Secret survives the AIService's deletion. Cluster restored and verified identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Title: feat(agent-runtime): delete only operator-owned objects and keep customer data (MPR-202)
Base:
ai-agent-runtimeHead:feat/MPR-202-owned-deletionSummary
Deleting an AgentRuntime feature now removes only the objects the operator created for it, through owner references and garbage collection. Customer data stays: the PostgreSQL database and checkpoint records, referenced Secrets, user-named ServiceAccounts and TLS Secrets, PVCs, model artifacts and shared infrastructure. Both profiles follow the same rules.
docs/agent-runtime/ownership-and-deletion.md. Validation record:docs/agent-runtime/mpr-202-validation.md. Captured cluster runs:docs/agent-runtime/validation/mpr-202-cluster.txt.What was wrong
Each of these was reproduced on a real API server before the fix:
features[].serviceAccountNamewas adopted (given the AIService as controller), so garbage collection would delete it with the AIService.<name>-tlswithout an owner, so it outlived the AIService.aiservice-protect/aiplatform-protectfinalizers, but their handlers remained. The platform's handler deleted children itself and held the platform until they were gone.InvalidSpecincluded.What it does
common.ClaimOrRefuse), applied to the ServiceAccount, ConfigMap, Certificate, schema Job, Deployment, Service, HPA and ServiceMonitor:OwnershipConflict, naming the object, and a Warning event is recorded;<name>-tlsgets a non-controller owner reference once cert-manager issues it for this Certificate, so it's removed with the AIService. A Secret named inmtls.secretNameis never owned.create/patchon coreeventsin the generated and Helm ClusterRoles. The test that keeps the two identical now also requires this rule.RefuseUnowned), so SAIA keeps adopting as before, with a test pinning that. Neither the ERD nor the story covers SAIA ownership.Commits
fix(rbac): let the operator record events on AIServices and AIPlatformsfeat(agent-runtime): delete only operator-owned objects and keep customer datadocs(agent-runtime): ownership inventory, deletion runbook and validation recordTesting done
go build,go vet; all 24 non-e2e packages pass; race detector clean on the changed packagesCluster (fullfeature-dev, 2026-11-24, retested 2026-11-25 on
9d4a0cdwith PR #290):OwnershipConflictcondition and Warning event, object unchanged, recovered after removalNot covered
-racewith some spec orders, on the base too, because older specs write the shared client-go scheme. The new specs use a private scheme.Found along the way
955dd11(MPR-189). Fixed by PR Stop redundant Deployment writes during reconciliation #290; the retest here shows 0.