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
8eeb2d13
Commit
8eeb2d13
authored
Feb 06, 2015
by
Dawn Chen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4206 from saad-ali/modifyEventStruct
Modify Event struct to allow compressing multiple recurring events in to a single event
parents
36b063dd
79cbcf91
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
148 additions
and
44 deletions
+148
-44
fuzzer.go
pkg/api/testing/fuzzer.go
+16
-0
types.go
pkg/api/types.go
+8
-2
conversion.go
pkg/api/v1beta1/conversion.go
+15
-2
types.go
pkg/api/v1beta1/types.go
+11
-0
conversion.go
pkg/api/v1beta2/conversion.go
+14
-2
types.go
pkg/api/v1beta2/types.go
+11
-0
types.go
pkg/api/v1beta3/types.go
+8
-2
events_test.go
pkg/client/events_test.go
+9
-3
event.go
pkg/client/record/event.go
+3
-1
event_test.go
pkg/client/record/event_test.go
+5
-2
describe.go
pkg/kubectl/describe.go
+1
-1
describe_test.go
pkg/kubectl/describe_test.go
+15
-9
resource_printer.go
pkg/kubectl/resource_printer.go
+1
-1
resource_printer_test.go
pkg/kubectl/resource_printer_test.go
+15
-9
sorted_event_list.go
pkg/kubectl/sorted_event_list.go
+1
-1
sorted_event_list_test.go
pkg/kubectl/sorted_event_list_test.go
+15
-9
No files found.
pkg/api/testing/fuzzer.go
View file @
8eeb2d13
...
...
@@ -211,6 +211,22 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer {
c
.
Fuzz
(
&
ct
.
Privileged
)
c
.
Fuzz
(
&
ct
.
Capabilities
)
},
func
(
e
*
api
.
Event
,
c
fuzz
.
Continue
)
{
// Fix event count to 1, otherwise, if a v1beta1 or v1beta2 event has a count set arbitrarily, it's count is ignored
c
.
Fuzz
(
&
e
.
TypeMeta
)
c
.
Fuzz
(
&
e
.
ObjectMeta
)
c
.
Fuzz
(
&
e
.
InvolvedObject
)
c
.
Fuzz
(
&
e
.
Reason
)
c
.
Fuzz
(
&
e
.
Message
)
c
.
Fuzz
(
&
e
.
Source
)
c
.
Fuzz
(
&
e
.
FirstTimestamp
)
c
.
Fuzz
(
&
e
.
LastTimestamp
)
if
e
.
FirstTimestamp
.
IsZero
()
{
e
.
Count
=
1
}
else
{
c
.
Fuzz
(
&
e
.
Count
)
}
},
)
return
f
}
pkg/api/types.go
View file @
8eeb2d13
...
...
@@ -1079,8 +1079,14 @@ type Event struct {
// Optional. The component reporting this event. Should be a short machine understandable string.
Source
EventSource
`json:"source,omitempty"`
// The time at which the client recorded the event. (Time of server receipt is in TypeMeta.)
Timestamp
util
.
Time
`json:"timestamp,omitempty"`
// The time at which the event was first recorded. (Time of server receipt is in TypeMeta.)
FirstTimestamp
util
.
Time
`json:"firstTimestamp,omitempty"`
// The time at which the most recent occurance of this event was recorded.
LastTimestamp
util
.
Time
`json:"lastTimestamp,omitempty"`
// The number of times this event has occurred.
Count
int
`json:"count,omitempty"`
}
// EventList is a list of events.
...
...
pkg/api/v1beta1/conversion.go
View file @
8eeb2d13
...
...
@@ -898,7 +898,11 @@ func init() {
out
.
Message
=
in
.
Message
out
.
Source
=
in
.
Source
.
Component
out
.
Host
=
in
.
Source
.
Host
out
.
Timestamp
=
in
.
Timestamp
out
.
Timestamp
=
in
.
FirstTimestamp
out
.
FirstTimestamp
=
in
.
FirstTimestamp
out
.
LastTimestamp
=
in
.
LastTimestamp
out
.
Count
=
in
.
Count
return
s
.
Convert
(
&
in
.
InvolvedObject
,
&
out
.
InvolvedObject
,
0
)
},
func
(
in
*
Event
,
out
*
newer
.
Event
,
s
conversion
.
Scope
)
error
{
...
...
@@ -912,7 +916,16 @@ func init() {
out
.
Message
=
in
.
Message
out
.
Source
.
Component
=
in
.
Source
out
.
Source
.
Host
=
in
.
Host
out
.
Timestamp
=
in
.
Timestamp
if
in
.
FirstTimestamp
.
IsZero
()
{
// Assume this is an old event that does not specify FirstTimestamp/LastTimestamp/Count
out
.
FirstTimestamp
=
in
.
Timestamp
out
.
LastTimestamp
=
in
.
Timestamp
out
.
Count
=
1
}
else
{
out
.
FirstTimestamp
=
in
.
FirstTimestamp
out
.
LastTimestamp
=
in
.
LastTimestamp
out
.
Count
=
in
.
Count
}
return
s
.
Convert
(
&
in
.
InvolvedObject
,
&
out
.
InvolvedObject
,
0
)
},
...
...
pkg/api/v1beta1/types.go
View file @
8eeb2d13
...
...
@@ -865,7 +865,18 @@ type Event struct {
Host
string
`json:"host,omitempty" description:"host name on which this event was generated"`
// The time at which the client recorded the event. (Time of server receipt is in TypeMeta.)
// Deprecated: Use InitialTimeStamp/LastSeenTimestamp/Count instead.
// For backwards compatability, this will map to IntialTimestamp.
Timestamp
util
.
Time
`json:"timestamp,omitempty" description:"time at which the client recorded the event"`
// The time at which the event was first recorded. (Time of server receipt is in TypeMeta.)
FirstTimestamp
util
.
Time
`json:"firstTimestamp,omitempty" description:"the time at which the event was first recorded"`
// The time at which the most recent occurance of this event was recorded.
LastTimestamp
util
.
Time
`json:"lastTimestamp,omitempty" description:"the time at which the most recent occurance of this event was recorded"`
// The number of times this event has occurred.
Count
int
`json:"count,omitempty" description:"the number of times this event has occurred"`
}
// EventList is a list of events.
...
...
pkg/api/v1beta2/conversion.go
View file @
8eeb2d13
...
...
@@ -819,7 +819,10 @@ func init() {
out
.
Message
=
in
.
Message
out
.
Source
=
in
.
Source
.
Component
out
.
Host
=
in
.
Source
.
Host
out
.
Timestamp
=
in
.
Timestamp
out
.
Timestamp
=
in
.
FirstTimestamp
out
.
FirstTimestamp
=
in
.
FirstTimestamp
out
.
LastTimestamp
=
in
.
LastTimestamp
out
.
Count
=
in
.
Count
return
s
.
Convert
(
&
in
.
InvolvedObject
,
&
out
.
InvolvedObject
,
0
)
},
func
(
in
*
Event
,
out
*
newer
.
Event
,
s
conversion
.
Scope
)
error
{
...
...
@@ -833,7 +836,16 @@ func init() {
out
.
Message
=
in
.
Message
out
.
Source
.
Component
=
in
.
Source
out
.
Source
.
Host
=
in
.
Host
out
.
Timestamp
=
in
.
Timestamp
if
in
.
FirstTimestamp
.
IsZero
()
{
// Assume this is an old event that does not specify FirstTimestamp/LastTimestamp/Count
out
.
FirstTimestamp
=
in
.
Timestamp
out
.
LastTimestamp
=
in
.
Timestamp
out
.
Count
=
1
}
else
{
out
.
FirstTimestamp
=
in
.
FirstTimestamp
out
.
LastTimestamp
=
in
.
LastTimestamp
out
.
Count
=
in
.
Count
}
return
s
.
Convert
(
&
in
.
InvolvedObject
,
&
out
.
InvolvedObject
,
0
)
},
...
...
pkg/api/v1beta2/types.go
View file @
8eeb2d13
...
...
@@ -840,7 +840,18 @@ type Event struct {
Host
string
`json:"host,omitempty" description:"host name on which this event was generated"`
// The time at which the client recorded the event. (Time of server receipt is in TypeMeta.)
// Deprecated: Use InitialTimeStamp/LastSeenTimestamp/Count instead.
// For backwards compatability, this will map to IntialTimestamp.
Timestamp
util
.
Time
`json:"timestamp,omitempty" description:"time at which the client recorded the event"`
// The time at which the event was first recorded. (Time of server receipt is in TypeMeta.)
FirstTimestamp
util
.
Time
`json:"firstTimestamp,omitempty" description:"the time at which the event was first recorded"`
// The time at which the most recent occurance of this event was recorded.
LastTimestamp
util
.
Time
`json:"lastTimestamp,omitempty" description:"the time at which the most recent occurance of this event was recorded"`
// The number of times this event has occurred.
Count
int
`json:"count,omitempty" description:"the number of times this event has occurred"`
}
// EventList is a list of events.
...
...
pkg/api/v1beta3/types.go
View file @
8eeb2d13
...
...
@@ -1058,8 +1058,14 @@ type Event struct {
// Optional. The component reporting this event. Should be a short machine understandable string.
Source
EventSource
`json:"source,omitempty"`
// The time at which the client recorded the event. (Time of server receipt is in TypeMeta.)
Timestamp
util
.
Time
`json:"timestamp,omitempty"`
// The time at which the event was first recorded. (Time of server receipt is in TypeMeta.)
FirstTimestamp
util
.
Time
`json:"firstTimestamp,omitempty"`
// The time at which the most recent occurance of this event was recorded.
LastTimestamp
util
.
Time
`json:"lastTimestamp,omitempty"`
// The number of times this event has occurred.
Count
int
`json:"count,omitempty"`
}
// EventList is a list of events.
...
...
pkg/client/events_test.go
View file @
8eeb2d13
...
...
@@ -64,7 +64,9 @@ func TestEventCreate(t *testing.T) {
event
:=
&
api
.
Event
{
//namespace: namespace{"default"},
InvolvedObject
:
*
objReference
,
Timestamp
:
timeStamp
,
FirstTimestamp
:
timeStamp
,
LastTimestamp
:
timeStamp
,
Count
:
1
,
}
c
:=
&
testClient
{
Request
:
testRequest
{
...
...
@@ -98,7 +100,9 @@ func TestEventGet(t *testing.T) {
timeStamp
:=
util
.
Now
()
event
:=
&
api
.
Event
{
InvolvedObject
:
*
objReference
,
Timestamp
:
timeStamp
,
FirstTimestamp
:
timeStamp
,
LastTimestamp
:
timeStamp
,
Count
:
1
,
}
c
:=
&
testClient
{
Request
:
testRequest
{
...
...
@@ -135,7 +139,9 @@ func TestEventList(t *testing.T) {
Items
:
[]
api
.
Event
{
{
InvolvedObject
:
*
objReference
,
Timestamp
:
timeStamp
,
FirstTimestamp
:
timeStamp
,
LastTimestamp
:
timeStamp
,
Count
:
1
,
},
},
}
...
...
pkg/client/record/event.go
View file @
8eeb2d13
...
...
@@ -170,7 +170,9 @@ func Event(object runtime.Object, reason, message string) {
InvolvedObject
:
*
ref
,
Reason
:
reason
,
Message
:
message
,
Timestamp
:
t
,
FirstTimestamp
:
t
,
LastTimestamp
:
t
,
Count
:
1
,
}
events
.
Action
(
watch
.
Added
,
e
)
...
...
pkg/client/record/event_test.go
View file @
8eeb2d13
...
...
@@ -93,6 +93,7 @@ func TestEventf(t *testing.T) {
Reason
:
"Started"
,
Message
:
"some verbose message: 1"
,
Source
:
api
.
EventSource
{
Component
:
"eventTest"
},
Count
:
1
,
},
expectLog
:
`Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1beta1", ResourceVersion:"", FieldPath:"desiredState.manifest.containers[2]"}): reason: 'Started' some verbose message: 1`
,
},
...
...
@@ -116,6 +117,7 @@ func TestEventf(t *testing.T) {
Reason
:
"Started"
,
Message
:
"some verbose message: 1"
,
Source
:
api
.
EventSource
{
Component
:
"eventTest"
},
Count
:
1
,
},
expectLog
:
`Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1beta1", ResourceVersion:"", FieldPath:""}): reason: 'Started' some verbose message: 1`
,
},
...
...
@@ -127,10 +129,11 @@ func TestEventf(t *testing.T) {
OnEvent
:
func
(
event
*
api
.
Event
)
(
*
api
.
Event
,
error
)
{
a
:=
*
event
// Just check that the timestamp was set.
if
a
.
Timestamp
.
IsZero
()
{
if
a
.
FirstTimestamp
.
IsZero
()
||
a
.
Last
Timestamp
.
IsZero
()
{
t
.
Errorf
(
"timestamp wasn't set"
)
}
a
.
Timestamp
=
item
.
expect
.
Timestamp
a
.
FirstTimestamp
=
item
.
expect
.
FirstTimestamp
a
.
LastTimestamp
=
item
.
expect
.
LastTimestamp
// Check that name has the right prefix.
if
n
,
en
:=
a
.
Name
,
item
.
expect
.
Name
;
!
strings
.
HasPrefix
(
n
,
en
)
{
t
.
Errorf
(
"Name '%v' does not contain prefix '%v'"
,
n
,
en
)
...
...
pkg/kubectl/describe.go
View file @
8eeb2d13
...
...
@@ -301,7 +301,7 @@ func describeEvents(el *api.EventList, w io.Writer) {
fmt
.
Fprint
(
w
,
"Events:
\n
Time
\t
From
\t
SubobjectPath
\t
Reason
\t
Message
\n
"
)
for
_
,
e
:=
range
el
.
Items
{
fmt
.
Fprintf
(
w
,
"%s
\t
%v
\t
%v
\t
%v
\t
%v
\n
"
,
e
.
Timestamp
.
Time
.
Format
(
time
.
RFC1123Z
),
e
.
First
Timestamp
.
Time
.
Format
(
time
.
RFC1123Z
),
e
.
Source
,
e
.
InvolvedObject
.
FieldPath
,
e
.
Reason
,
...
...
pkg/kubectl/describe_test.go
View file @
8eeb2d13
...
...
@@ -69,19 +69,25 @@ func TestPodDescribeResultsSorted(t *testing.T) {
EventsList
:
api
.
EventList
{
Items
:
[]
api
.
Event
{
{
Source
:
api
.
EventSource
{
Component
:
"kubelet"
},
Message
:
"Item 1"
,
Timestamp
:
util
.
NewTime
(
time
.
Date
(
2014
,
time
.
January
,
15
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Source
:
api
.
EventSource
{
Component
:
"kubelet"
},
Message
:
"Item 1"
,
FirstTimestamp
:
util
.
NewTime
(
time
.
Date
(
2014
,
time
.
January
,
15
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
LastTimestamp
:
util
.
NewTime
(
time
.
Date
(
2014
,
time
.
January
,
15
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Count
:
1
,
},
{
Source
:
api
.
EventSource
{
Component
:
"scheduler"
},
Message
:
"Item 2"
,
Timestamp
:
util
.
NewTime
(
time
.
Date
(
1987
,
time
.
June
,
17
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Source
:
api
.
EventSource
{
Component
:
"scheduler"
},
Message
:
"Item 2"
,
FirstTimestamp
:
util
.
NewTime
(
time
.
Date
(
1987
,
time
.
June
,
17
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
LastTimestamp
:
util
.
NewTime
(
time
.
Date
(
1987
,
time
.
June
,
17
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Count
:
1
,
},
{
Source
:
api
.
EventSource
{
Component
:
"kubelet"
},
Message
:
"Item 3"
,
Timestamp
:
util
.
NewTime
(
time
.
Date
(
2002
,
time
.
December
,
25
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Source
:
api
.
EventSource
{
Component
:
"kubelet"
},
Message
:
"Item 3"
,
FirstTimestamp
:
util
.
NewTime
(
time
.
Date
(
2002
,
time
.
December
,
25
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
LastTimestamp
:
util
.
NewTime
(
time
.
Date
(
2002
,
time
.
December
,
25
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Count
:
1
,
},
},
},
...
...
pkg/kubectl/resource_printer.go
View file @
8eeb2d13
...
...
@@ -407,7 +407,7 @@ func printStatus(status *api.Status, w io.Writer) error {
func
printEvent
(
event
*
api
.
Event
,
w
io
.
Writer
)
error
{
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\t
%s
\t
%s
\t
%s
\t
%s
\t
%s
\n
"
,
event
.
Timestamp
.
Time
.
Format
(
time
.
RFC1123Z
),
event
.
First
Timestamp
.
Time
.
Format
(
time
.
RFC1123Z
),
event
.
InvolvedObject
.
Name
,
event
.
InvolvedObject
.
Kind
,
event
.
InvolvedObject
.
FieldPath
,
...
...
pkg/kubectl/resource_printer_test.go
View file @
8eeb2d13
...
...
@@ -480,19 +480,25 @@ func TestPrintEventsResultSorted(t *testing.T) {
obj
:=
api
.
EventList
{
Items
:
[]
api
.
Event
{
{
Source
:
api
.
EventSource
{
Component
:
"kubelet"
},
Message
:
"Item 1"
,
Timestamp
:
util
.
NewTime
(
time
.
Date
(
2014
,
time
.
January
,
15
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Source
:
api
.
EventSource
{
Component
:
"kubelet"
},
Message
:
"Item 1"
,
FirstTimestamp
:
util
.
NewTime
(
time
.
Date
(
2014
,
time
.
January
,
15
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
LastTimestamp
:
util
.
NewTime
(
time
.
Date
(
2014
,
time
.
January
,
15
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Count
:
1
,
},
{
Source
:
api
.
EventSource
{
Component
:
"scheduler"
},
Message
:
"Item 2"
,
Timestamp
:
util
.
NewTime
(
time
.
Date
(
1987
,
time
.
June
,
17
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Source
:
api
.
EventSource
{
Component
:
"scheduler"
},
Message
:
"Item 2"
,
FirstTimestamp
:
util
.
NewTime
(
time
.
Date
(
1987
,
time
.
June
,
17
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
LastTimestamp
:
util
.
NewTime
(
time
.
Date
(
1987
,
time
.
June
,
17
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Count
:
1
,
},
{
Source
:
api
.
EventSource
{
Component
:
"kubelet"
},
Message
:
"Item 3"
,
Timestamp
:
util
.
NewTime
(
time
.
Date
(
2002
,
time
.
December
,
25
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Source
:
api
.
EventSource
{
Component
:
"kubelet"
},
Message
:
"Item 3"
,
FirstTimestamp
:
util
.
NewTime
(
time
.
Date
(
2002
,
time
.
December
,
25
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
LastTimestamp
:
util
.
NewTime
(
time
.
Date
(
2002
,
time
.
December
,
25
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Count
:
1
,
},
},
}
...
...
pkg/kubectl/sorted_event_list.go
View file @
8eeb2d13
...
...
@@ -32,5 +32,5 @@ func (list SortableEvents) Swap(i, j int) {
}
func
(
list
SortableEvents
)
Less
(
i
,
j
int
)
bool
{
return
list
[
i
]
.
Timestamp
.
Time
.
Before
(
list
[
j
]
.
Timestamp
.
Time
)
return
list
[
i
]
.
LastTimestamp
.
Time
.
Before
(
list
[
j
]
.
Last
Timestamp
.
Time
)
}
pkg/kubectl/sorted_event_list_test.go
View file @
8eeb2d13
...
...
@@ -55,19 +55,25 @@ func TestSortableEvents(t *testing.T) {
// Arrange
list
:=
SortableEvents
([]
api
.
Event
{
{
Source
:
api
.
EventSource
{
Component
:
"kubelet"
},
Message
:
"Item 1"
,
Timestamp
:
util
.
NewTime
(
time
.
Date
(
2014
,
time
.
January
,
15
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Source
:
api
.
EventSource
{
Component
:
"kubelet"
},
Message
:
"Item 1"
,
FirstTimestamp
:
util
.
NewTime
(
time
.
Date
(
2014
,
time
.
January
,
15
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
LastTimestamp
:
util
.
NewTime
(
time
.
Date
(
2014
,
time
.
January
,
15
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Count
:
1
,
},
{
Source
:
api
.
EventSource
{
Component
:
"scheduler"
},
Message
:
"Item 2"
,
Timestamp
:
util
.
NewTime
(
time
.
Date
(
1987
,
time
.
June
,
17
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Source
:
api
.
EventSource
{
Component
:
"scheduler"
},
Message
:
"Item 2"
,
FirstTimestamp
:
util
.
NewTime
(
time
.
Date
(
1987
,
time
.
June
,
17
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
LastTimestamp
:
util
.
NewTime
(
time
.
Date
(
1987
,
time
.
June
,
17
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Count
:
1
,
},
{
Source
:
api
.
EventSource
{
Component
:
"kubelet"
},
Message
:
"Item 3"
,
Timestamp
:
util
.
NewTime
(
time
.
Date
(
2002
,
time
.
December
,
25
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Source
:
api
.
EventSource
{
Component
:
"kubelet"
},
Message
:
"Item 3"
,
FirstTimestamp
:
util
.
NewTime
(
time
.
Date
(
2002
,
time
.
December
,
25
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
LastTimestamp
:
util
.
NewTime
(
time
.
Date
(
2002
,
time
.
December
,
25
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Count
:
1
,
},
})
...
...
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