Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include object fieldpath in event key #47973

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions staging/src/k8s.io/client-go/tools/record/events_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func getEventKey(event *v1.Event) string {
event.InvolvedObject.Kind,
event.InvolvedObject.Namespace,
event.InvolvedObject.Name,
event.InvolvedObject.FieldPath,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes sense. aggregator bumped the count since the message didn't vary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

string(event.InvolvedObject.UID),
event.InvolvedObject.APIVersion,
event.Type,
Expand Down
10 changes: 10 additions & 0 deletions staging/src/k8s.io/client-go/tools/record/events_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func makeObjectReference(kind, name, namespace string) v1.ObjectReference {
Namespace: namespace,
UID: "C934D34AFB20242",
APIVersion: "version",
FieldPath: "spec.containers{mycontainer}",
}
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down