From 8e9dfea2c46310a4a517751b7009bd38f922750c Mon Sep 17 00:00:00 2001 From: Damien Grisonnet Date: Thu, 8 Sep 2022 23:50:41 +0200 Subject: [PATCH] events: fix EventSeries starting count discrepancy The kube-apiserver validation expects the Count of an EventSeries to be at least 2, otherwise it rejects the Event. There was is discrepancy between the client and the server since the client was iniatizing an EventSeries to a count of 1. According to the original KEP, the first event emitted should have an EventSeries set to nil and the second isomorphic event should have an EventSeries with a count of 2. Thus, we should matcht the behavior define by the KEP and update the client. Also, as an effort to make the old clients compatible with the servers, we should allow Events with an EventSeries count of 1 to prevent any unexpected rejections. Signed-off-by: Damien Grisonnet Kubernetes-commit: 11716b1267daed5e50a52a987492827b2083c052 --- tools/events/event_broadcaster.go | 2 +- tools/events/eventseries_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/events/event_broadcaster.go b/tools/events/event_broadcaster.go index 309927bab..7a9435637 100644 --- a/tools/events/event_broadcaster.go +++ b/tools/events/event_broadcaster.go @@ -181,7 +181,7 @@ func (e *eventBroadcasterImpl) recordToSink(event *eventsv1.Event, clock clock.C return nil } isomorphicEvent.Series = &eventsv1.EventSeries{ - Count: 1, + Count: 2, LastObservedTime: metav1.MicroTime{Time: clock.Now()}, } // Make a copy of the Event to make sure that recording it diff --git a/tools/events/eventseries_test.go b/tools/events/eventseries_test.go index 36476917a..a7bedc71e 100644 --- a/tools/events/eventseries_test.go +++ b/tools/events/eventseries_test.go @@ -108,7 +108,7 @@ func TestEventSeriesf(t *testing.T) { nonIsomorphicEvent := expectedEvent.DeepCopy() nonIsomorphicEvent.Action = "stopped" - expectedEvent.Series = &eventsv1.EventSeries{Count: 1} + expectedEvent.Series = &eventsv1.EventSeries{Count: 2} table := []struct { regarding k8sruntime.Object related k8sruntime.Object