buehler/dotnet-operator-sdk

[bug]: Events are not correctly generated in relation with the source entity

oionut opened this issue · 2 comments

oionut commented

Describe the bug

The wrong event instance is updated

To reproduce

  1. Create a CR (CR1) and publish an event await eventPublisher(entity, "RECONCILED", "Entity was reconciled.");
  2. Delete the CR
  3. Create a new CR (CR2) and and publish an event with the same message as await eventPublisher(entity, "RECONCILED", "Entity was reconciled.");

When running the kubectl describe CR1 no event is listed

Note: run the same scenario without step 2, the event published for the CR2 entity is visible only on CR1

Expected behavior

When running the kubectl describe CR1, one event should be listed

Screenshots

No response

Additional Context

Potential fix: in

var eventName = $"{entity.Name()}.{@namespace}.{reason}.{message}.{type}";
, include in the event name the entity UID in order to link the name to the specific entity the event is generated for.

oionut commented

anther option would be to provide an overload that allows setting the event name from outside

Hey @oionut

I think you are right with your suggestion to add the entity uid (instead of name).