Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
fbcb0562
Commit
fbcb0562
authored
Jun 23, 2017
by
Seth Jennings
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
include object fieldpath in event key
parent
72cb080c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
events_cache.go
staging/src/k8s.io/client-go/tools/record/events_cache.go
+1
-0
events_cache_test.go
...ng/src/k8s.io/client-go/tools/record/events_cache_test.go
+10
-0
No files found.
staging/src/k8s.io/client-go/tools/record/events_cache.go
View file @
fbcb0562
...
@@ -49,6 +49,7 @@ func getEventKey(event *v1.Event) string {
...
@@ -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
,
...
...
staging/src/k8s.io/client-go/tools/record/events_cache_test.go
View file @
fbcb0562
...
@@ -35,6 +35,7 @@ func makeObjectReference(kind, name, namespace string) v1.ObjectReference {
...
@@ -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) {
...
@@ -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) {
...
@@ -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
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment