mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
include object fieldpath in event key
This commit is contained in:
parent
72cb080c87
commit
fbcb0562ea
@ -49,6 +49,7 @@ func getEventKey(event *v1.Event) string {
|
||||
event.InvolvedObject.Kind,
|
||||
event.InvolvedObject.Namespace,
|
||||
event.InvolvedObject.Name,
|
||||
event.InvolvedObject.FieldPath,
|
||||
string(event.InvolvedObject.UID),
|
||||
event.InvolvedObject.APIVersion,
|
||||
event.Type,
|
||||
|
@ -35,6 +35,7 @@ func makeObjectReference(kind, name, namespace string) v1.ObjectReference {
|
||||
Namespace: namespace,
|
||||
UID: "C934D34AFB20242",
|
||||
APIVersion: "version",
|
||||
FieldPath: "spec.containers{mycontainer}",
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,7 +172,10 @@ func TestEventCorrelator(t *testing.T) {
|
||||
duplicateEvent := makeEvent("duplicate", "me again", makeObjectReference("Pod", "my-pod", "my-ns"))
|
||||
uniqueEvent := makeEvent("unique", "snowflake", makeObjectReference("Pod", "my-pod", "my-ns"))
|
||||
similarEvent := makeEvent("similar", "similar message", makeObjectReference("Pod", "my-pod", "my-ns"))
|
||||
similarEvent.InvolvedObject.FieldPath = "spec.containers{container1}"
|
||||
aggregateEvent := makeEvent(similarEvent.Reason, EventAggregatorByReasonMessageFunc(&similarEvent), similarEvent.InvolvedObject)
|
||||
similarButDifferentContainerEvent := similarEvent
|
||||
similarButDifferentContainerEvent.InvolvedObject.FieldPath = "spec.containers{container2}"
|
||||
scenario := map[string]struct {
|
||||
previousEvents []v1.Event
|
||||
newEvent v1.Event
|
||||
@ -214,6 +218,12 @@ func TestEventCorrelator(t *testing.T) {
|
||||
expectedEvent: setCount(aggregateEvent, 2),
|
||||
intervalSeconds: 5,
|
||||
},
|
||||
"events-from-different-containers-do-not-aggregate": {
|
||||
previousEvents: makeEvents(1, similarButDifferentContainerEvent),
|
||||
newEvent: similarEvent,
|
||||
expectedEvent: setCount(similarEvent, 1),
|
||||
intervalSeconds: 5,
|
||||
},
|
||||
"similar-events-whose-interval-is-greater-than-aggregate-interval-do-not-aggregate": {
|
||||
previousEvents: makeSimilarEvents(defaultAggregateMaxEvents-1, similarEvent, similarEvent.Message),
|
||||
newEvent: similarEvent,
|
||||
|
Loading…
Reference in New Issue
Block a user