fix: transform operand manifests from pristine copies #342
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 385 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.356
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #342"
general
weight: 0.35
joelsmith
The reconciler loads the operand manifests once at start-up, but each install then transformed them and stored the result back into
r.resources, so the next reconcile transformed an already-transformed manifest. The transformers only add or overwrite entries, never remove them, so anything deleted from theKedaControllerspec stayed in the cached desired state and kept being applied. Clearing a field had no effect until the operator process restarted.This keeps the start-up manifests in new
pristinefields and transforms from those on every reconcile.r.resources*still holds the last applied result, which is what the finalizer deletes through.Two properties of the existing code keep the change small:
manifestival.Transformdeep-copies (result.resources = m.Resources()), so the pristine manifests cannot be corrupted by a transform and need no defensive copying.InjectOwner+ReplaceAllNamespaces, so transforming from pristine still yields a fully namespace-resolved manifest and the finalizer's delete paths are unchanged.It also fixes both failure modes without touching any of the
if len(...) > 0guards. Append-only transforms now only add what is currently in the spec, and guarded total-replacement transforms fall back to the operand manifest's value when the guard skips them, instead of to the previously applied value.Affected fields are every spec-driven one, not just
env: args, deployment annotations and labels, node selectors, tolerations, affinity, resource requirements, priority class names, and the network policy pod selectors.This was reported by CodeRabbit while reviewing the
envwork in #335, but it is not a regression from that PR — the manifest caching long predates it.Testing
Added envtest removal coverage for all three components. Each spec sets
env, waits for the rollout, deletesenv, then asserts that the appended variable is gone and thatKEDA_HTTP_DEFAULT_TIMEOUTis back to the empty value fromresources/keda.yaml. That second assertion is the important one: it proves the desired state really returns to pristine rather than merely stopping at "didn't add anything new".The suite's
BeforeEachwaits for the defaultKedaControllerto reach the client cache first, otherwiseApplyraces the operator creating it at start-up and fails withkedacontrollers.keda.sh "keda" already exists.The full functionality suite fails three specs that need a real cluster with running pods (
Deploying KedaController manifestand one annotation spec). A baseline run atmainin a clean worktree fails the identical specs, so they are pre-existing under envtest.Note for reviewers
The behavior change is that clearing a spec field now actually takes effect. Any cluster relying on a value that was only surviving because of this bug will see it disappear on the first reconcile after upgrade.
Checklist