mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-28 16:07:29 +00:00
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 <dgrisonn@redhat.com> Kubernetes-commit: d00364902bda05eed4f7f02051ab81f7be55f8a9
This commit is contained in:
parent
3cafc13f5d
commit
9c7c60b695
@ -183,7 +183,7 @@ func (e *eventBroadcasterImpl) recordToSink(event *eventsv1.Event, clock clock.C
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
isomorphicEvent.Series = &eventsv1.EventSeries{
|
isomorphicEvent.Series = &eventsv1.EventSeries{
|
||||||
Count: 1,
|
Count: 2,
|
||||||
LastObservedTime: metav1.MicroTime{Time: clock.Now()},
|
LastObservedTime: metav1.MicroTime{Time: clock.Now()},
|
||||||
}
|
}
|
||||||
// Make a copy of the Event to make sure that recording it
|
// Make a copy of the Event to make sure that recording it
|
||||||
|
@ -108,7 +108,7 @@ func TestEventSeriesf(t *testing.T) {
|
|||||||
nonIsomorphicEvent := expectedEvent.DeepCopy()
|
nonIsomorphicEvent := expectedEvent.DeepCopy()
|
||||||
nonIsomorphicEvent.Action = "stopped"
|
nonIsomorphicEvent.Action = "stopped"
|
||||||
|
|
||||||
expectedEvent.Series = &eventsv1.EventSeries{Count: 1}
|
expectedEvent.Series = &eventsv1.EventSeries{Count: 2}
|
||||||
table := []struct {
|
table := []struct {
|
||||||
regarding k8sruntime.Object
|
regarding k8sruntime.Object
|
||||||
related k8sruntime.Object
|
related k8sruntime.Object
|
||||||
|
Loading…
Reference in New Issue
Block a user