fix(controller): pass message format as the event note, not the action #3311
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 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.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3311"
general
weight: 0.35
nabuskey
Purpose of this PR
Since v2.6.0 every event the SparkApplication controller records has the wrong message: the message is only the app or pod name, and executor events contain
%!(EXTRA ...). This PR passes anactionto eachEventfcall so the message format string goes back intonote, where it belongs.Fixes #3308
Proposed changes:
actionargument ("Reconcile") to the 20Eventfcalls incontroller.go:recordSparkApplicationEvent,recordDriverEvent,recordExecutorEvent, and the driver-not-found event inupdateDriverState.actionargument ("Update") to the 2Eventfcalls inevent_filter.go.app.Nameargument inrecordExecutorEvent, so"Executor %s ..."is filled with the executor pod name again.Change Category
Rationale
Root cause
#2946 moved the controller from
record.EventRecordertoevents.EventRecorder. The twoEventfsignatures differ:The call sites gained the
relatedargument (nil) but noaction. The old message format string is therefore passed asaction, and the first format argument (the app or pod name) becomesnote. The recorder builds the message withfmt.Sprintf(note, args...), so the message is just the name, and any remaining arguments are reported as%!(EXTRA ...).In the same change
recordExecutorEventstarted passingapp.Namebeforeargs...:https://github.com/kubeflow/spark-operator/blob/5a95d6877f48a7130f57c79aab223ffef0558188/internal/controller/sparkapplication/controller.go#L1495-L1508
Reproduction
events.FakeRecorderformats the note the same way as the real recorder, so the new tests show the problem directly. On master:Fix
Insert one
actionstring at each call site and leave every message format string unchanged.actionmust be non-empty, machine-readable and at most 128 characters (k8s.io/api/events/v1). I usedReconcilefor events recorded by the reconciler andUpdatefor the two events recorded while the event filter handles an update event, as proposed in #3308. If you prefer other names, they are easy to change.Alternatives considered:
mgr.GetEventRecorderFor(the old API). It is deprecated in controller-runtime v0.23 and would undo #2946.recordEvent(app, type, reason, format, args...)that fills in the action. It adds an abstraction and a larger diff for the same result.Checklist
Additional Notes
Impact on existing users
Event messages go back to the text they had before v2.6.0, for example
SparkApplication spark-pi was submitted successfullyinstead ofspark-pi. Theactionfield changes from the raw format string toReconcileorUpdate. Event types and reasons do not change. Anyone who started matching on the broken v2.6.0 messages would notice; I could not find anything in this repo that depends on the message text. No API, CRD or RBAC change (events.k8s.iois already granted).Testing
TestRecordSparkApplicationEvent,TestRecordDriverEventandTestRecordExecutorEvent(controller_events_test.go, 19 cases covering every state of the three helpers). All 19 cases fail on master with output like the above, and pass with this change."...ound non-ex..."vs"...ound Driver...") and passes with this change.make go-fmt→ formatted,make go-vet→ pass,golangci-lint run(root module) →0 issues,make unit-test→ all packagesok.Not tested
event_filter.goevents have no direct test. Reaching them needs thePartialRestartgate or a failing status update in the filter, and the change there is the same one-argument insertion as the others.kubectl describeon a live cluster or run the e2e suite (needs Kind).test/e2emodule, because this change does not touch it.I used an AI assistant while working on this. I reviewed every change and ran the tests myself.