You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
EventRecorder: default aggregation key, ownerReference support, and naming control #3601
Is your feature request related to a problem? Please describe.
The new EventRecorder is exactly the thing we've been hand-rolling in our operator for years, so 5.6.0 was the trigger to try to finally delete our own implementation. We got close, but three things stopped us. Raising them now while the API is still experimental, in case you're open to shaping it a bit further.
The message is part of the event identity by default. Our health events carry live detail in the message (current pod states and so on), so every message change becomes a new Event object. For this kind of "current status" event that's not great: old states hang around as separate rows in kubectl get events until the TTL cleans them up, and during an incident the object count grows with every distinct message. Now, EventRecord.key() already solves this nicely, we tried it on a real cluster and with a key set the repeats patch count, lastTimestamp and message in place, giving the classic (x12 over 3m) in kubectl describe. The catch is that key() has to be set on every single record. We have around 40 emission sites, and one forgotten key() silently falls back to one-object-per-message.
No ownerReference. There's no way to tie a recorded event to the resource it's about, so after someone deletes the CR its events stick around until the TTL expires.
No control over the event name. Names are always <resource>.<hash>. Our current events have predictable names (<resource>-<event-name>) and it turns out people actually rely on that, we found scripts doing kubectl get event <name>. So switching to the recorder as-is would break them.
Describe the solution you'd like
A default aggregation-key strategy at recorder or controller level, something like "aggregate by reason", so context.eventRecorder().normal(reason, message) just does the right thing without per-call setup. Per-record key() stays as the override.
An opt-in flag to set the ownerReference to the regarding object.
Let the record (or recorder config) supply the event name or a naming strategy, hash stays the default. A per-reason name gives you the same guarantees the hash provides (no collisions, stable across restarts and replicas), just readable.
Happy to contribute any of these if you like the direction. Also happy to split this into three issues if that works better for you.
Describe alternatives you've considered
Keeping our own implementation, which is what we're doing for now. It works, but it's ~100 lines plus tests that do what EventRecorder almost does, and we'd rather be on the SDK. A wrapper that injects key() everywhere would only fix the first point and adds a layer we don't want to own.
Hi @afalhambra-hivemq , thank you for you feedback, this is gold. Let's iterate over this for the next minor release, so we can find a nice refined way to do this so it suits you also the community in general!
Note that I will also add a low level event recorder probably to faboric8 client, that will be aware of your suggestions too. But if you could prepare a PR for your points would be great, if not we will take a look. thank you again!
Activity
csviri commentedon Sep 7, 2026
Hi @afalhambra-hivemq , thank you for you feedback, this is gold. Let's iterate over this for the next minor release, so we can find a nice refined way to do this so it suits you also the community in general!
Note that I will also add a low level event recorder probably to faboric8 client, that will be aware of your suggestions too. But if you could prepare a PR for your points would be great, if not we will take a look. thank you again!
afalhambra-hivemq commentedon Sep 7, 2026
Thanks for your quick reply @csviri! Sure thing, let me prepare a PR for those.
csviri commentedon Sep 7, 2026
cc @TQJADE
afalhambra-hivemq commentedon Sep 9, 2026
Implementation done and merged.
Closing the issue now, thanks @csviri for your review!