Merge pull request #133777 from yshngg/patch/tautological-condition

refactor(event): simplify conditional logic in event handling

Kubernetes-commit: 98df6dde86a0e6f17607c825050dbee02af43d8b
This commit is contained in:
Kubernetes Publisher
2025-09-10 18:47:55 -07:00
4 changed files with 5 additions and 5 deletions

2
go.mod
View File

@@ -26,7 +26,7 @@ require (
google.golang.org/protobuf v1.36.8
gopkg.in/evanphx/json-patch.v4 v4.13.0
k8s.io/api v0.0.0-20250910154843-1fa0d26cdf76
k8s.io/apimachinery v0.0.0-20250910154559-505905675348
k8s.io/apimachinery v0.0.0-20250910225611-100e5eee9b94
k8s.io/klog/v2 v2.130.1
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397

4
go.sum
View File

@@ -150,8 +150,8 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/api v0.0.0-20250910154843-1fa0d26cdf76 h1:LClGpQ84ltOdzxjziPEYm2NytS8wlLsNWuRjFZPqs04=
k8s.io/api v0.0.0-20250910154843-1fa0d26cdf76/go.mod h1:PJ8lBYC0ACxXtw8039EoZbQpH1jObX2uJcQq+AtMFbM=
k8s.io/apimachinery v0.0.0-20250910154559-505905675348 h1:a3sxx4Oe6kASeOXy+jKuNT10on+c4MYCYaaNM2GokMQ=
k8s.io/apimachinery v0.0.0-20250910154559-505905675348/go.mod h1:e4PlUo2z96rImpZLr3O4JWowzW30ALyjsbqt07xJKSM=
k8s.io/apimachinery v0.0.0-20250910225611-100e5eee9b94 h1:0/+PV1z/hEqYcNLwL61R7uPoDqqqA521Yt61zjI2eBk=
k8s.io/apimachinery v0.0.0-20250910225611-100e5eee9b94/go.mod h1:e4PlUo2z96rImpZLr3O4JWowzW30ALyjsbqt07xJKSM=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b h1:MloQ9/bdJyIu9lb1PzujOPolHyvO06MXG5TUIj2mNAA=

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)