refactor(event): simplify conditional logic in event handling for both v1 and eventsv1 APIs

Signed-off-by: yshngg <yshngg@outlook.com>

Kubernetes-commit: 7685612b9c24c3129e0e17a6f6874b5902de02a1
This commit is contained in:
yshngg
2025-08-29 17:02:56 +08:00
committed by Kubernetes Publisher
parent 81eaeec477
commit dc29e94395
2 changed files with 2 additions and 2 deletions

View File

@@ -240,7 +240,7 @@ func recordEvent(ctx context.Context, sink EventSink, event *eventsv1.Event) (*e
newEvent, err = sink.Patch(ctx, event, patch)
}
// Update can fail because the event may have been removed and it no longer exists.
if !isEventSeries || (isEventSeries && util.IsKeyNotFoundError(err)) {
if !isEventSeries || util.IsKeyNotFoundError(err) {
// Making sure that ResourceVersion is empty on creation
event.ResourceVersion = ""
newEvent, err = sink.Create(ctx, event)

View File

@@ -334,7 +334,7 @@ func recordEvent(ctx context.Context, sink EventSink, event *v1.Event, patch []b
newEvent, err = sink.Patch(event, patch)
}
// Update can fail because the event may have been removed and it no longer exists.
if !updateExistingEvent || (updateExistingEvent && util.IsKeyNotFoundError(err)) {
if !updateExistingEvent || util.IsKeyNotFoundError(err) {
// Making sure that ResourceVersion is empty on creation
event.ResourceVersion = ""
newEvent, err = sink.Create(event)