mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-04 16:40:21 +00:00
include object fieldpath in event key
Kubernetes-commit: fbcb0562ea80a311e3e41ea43705097097ebb31c
This commit is contained in:
committed by
Kubernetes Publisher
parent
ed0ae8c707
commit
959d3293e8
@@ -49,6 +49,7 @@ func getEventKey(event *v1.Event) string {
|
|||||||
event.InvolvedObject.Kind,
|
event.InvolvedObject.Kind,
|
||||||
event.InvolvedObject.Namespace,
|
event.InvolvedObject.Namespace,
|
||||||
event.InvolvedObject.Name,
|
event.InvolvedObject.Name,
|
||||||
|
event.InvolvedObject.FieldPath,
|
||||||
string(event.InvolvedObject.UID),
|
string(event.InvolvedObject.UID),
|
||||||
event.InvolvedObject.APIVersion,
|
event.InvolvedObject.APIVersion,
|
||||||
event.Type,
|
event.Type,
|
||||||
|
@@ -35,6 +35,7 @@ func makeObjectReference(kind, name, namespace string) v1.ObjectReference {
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
UID: "C934D34AFB20242",
|
UID: "C934D34AFB20242",
|
||||||
APIVersion: "version",
|
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"))
|
duplicateEvent := makeEvent("duplicate", "me again", makeObjectReference("Pod", "my-pod", "my-ns"))
|
||||||
uniqueEvent := makeEvent("unique", "snowflake", 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 := makeEvent("similar", "similar message", makeObjectReference("Pod", "my-pod", "my-ns"))
|
||||||
|
similarEvent.InvolvedObject.FieldPath = "spec.containers{container1}"
|
||||||
aggregateEvent := makeEvent(similarEvent.Reason, EventAggregatorByReasonMessageFunc(&similarEvent), similarEvent.InvolvedObject)
|
aggregateEvent := makeEvent(similarEvent.Reason, EventAggregatorByReasonMessageFunc(&similarEvent), similarEvent.InvolvedObject)
|
||||||
|
similarButDifferentContainerEvent := similarEvent
|
||||||
|
similarButDifferentContainerEvent.InvolvedObject.FieldPath = "spec.containers{container2}"
|
||||||
scenario := map[string]struct {
|
scenario := map[string]struct {
|
||||||
previousEvents []v1.Event
|
previousEvents []v1.Event
|
||||||
newEvent v1.Event
|
newEvent v1.Event
|
||||||
@@ -214,6 +218,12 @@ func TestEventCorrelator(t *testing.T) {
|
|||||||
expectedEvent: setCount(aggregateEvent, 2),
|
expectedEvent: setCount(aggregateEvent, 2),
|
||||||
intervalSeconds: 5,
|
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": {
|
"similar-events-whose-interval-is-greater-than-aggregate-interval-do-not-aggregate": {
|
||||||
previousEvents: makeSimilarEvents(defaultAggregateMaxEvents-1, similarEvent, similarEvent.Message),
|
previousEvents: makeSimilarEvents(defaultAggregateMaxEvents-1, similarEvent, similarEvent.Message),
|
||||||
newEvent: similarEvent,
|
newEvent: similarEvent,
|
||||||
|
Reference in New Issue
Block a user