Skip to content

Conversation

@william-richard
Copy link

@william-richard william-richard commented Sep 15, 2025

💸 TL;DR

This PR adds optional dedupe logic to the events package. If enabled, It looks at the existing events on the Resource, and if an identical event exists, it does not record the event.

🧪 Testing Steps / Validation

I've just tested using my brain and the unit tests - I'd love advice for how I can test this against a real cluster.

✅ Checks

  • CI tests (if present) are passing
  • Adheres to code style for repo
  • Contributor License Agreement (CLA) completed if not a Reddit employee

- Add deduplicationEnabled parameter to RecordEvent and RecordWarning
- RecordReady always uses deduplication
- Add comprehensive tests for all deduplication scenarios
@william-richard william-richard changed the title Will k8s event dedupe Event dedupe logic Sep 15, 2025

// Check if any existing event matches the type, reason, and message
for _, event := range eventList.Items {
if event.Type == eventType && event.Reason == reason && event.Message == message {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me think about this more deeply because I think we might want some additional complexity here or still require client to do some work. As an example if I am marking my object as ready in an event, I want to capture what metadata.generation the object is ready at. If the current generation is 5 but we marked it ready for generation 1, the event is eventually not useful.

More and more it feels like its up to the client to determine what the dedup logic is so if we are going to add to the sdk, I just want to think a bit more deeply. Curious on your thoughts as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants