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
f11f0de4
Commit
f11f0de4
authored
Jan 06, 2015
by
Eric Tune
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3251 from dchen1107/cleanup
Surfacing events for pods created by config files.
parents
3a4d5fd6
e3c01912
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
72 additions
and
31 deletions
+72
-31
types.go
pkg/api/types.go
+8
-2
conversion.go
pkg/api/v1beta1/conversion.go
+7
-3
types.go
pkg/api/v1beta1/types.go
+2
-0
conversion.go
pkg/api/v1beta2/conversion.go
+7
-3
types.go
pkg/api/v1beta2/types.go
+3
-0
types.go
pkg/api/v1beta3/types.go
+8
-2
event.go
pkg/client/record/event.go
+2
-2
event_test.go
pkg/client/record/event_test.go
+4
-4
describe_test.go
pkg/kubectl/describe_test.go
+3
-3
resource_printer.go
pkg/kubectl/resource_printer.go
+3
-2
resource_printer_test.go
pkg/kubectl/resource_printer_test.go
+3
-3
sorted_event_list_test.go
pkg/kubectl/sorted_event_list_test.go
+3
-3
file.go
pkg/kubelet/config/file.go
+5
-0
file_test.go
pkg/kubelet/config/file_test.go
+3
-0
util.go
pkg/kubelet/util.go
+7
-1
rest.go
pkg/registry/event/rest.go
+1
-1
rest_test.go
pkg/registry/event/rest_test.go
+1
-1
scheduler.go
plugin/cmd/kube-scheduler/scheduler.go
+2
-1
No files found.
pkg/api/types.go
View file @
f11f0de4
...
@@ -985,6 +985,13 @@ type ObjectReference struct {
...
@@ -985,6 +985,13 @@ type ObjectReference struct {
FieldPath
string
`json:"fieldPath,omitempty"`
FieldPath
string
`json:"fieldPath,omitempty"`
}
}
type
EventSource
struct
{
// Component from which the event is generated.
Component
string
`json:"component,omitempty"`
// Host name on which the event is generated.
Host
string
`json:"host,omitempty"`
}
// Event is a report of an event somewhere in the cluster.
// Event is a report of an event somewhere in the cluster.
// TODO: Decide whether to store these separately or with the object they apply to.
// TODO: Decide whether to store these separately or with the object they apply to.
type
Event
struct
{
type
Event
struct
{
...
@@ -1014,8 +1021,7 @@ type Event struct {
...
@@ -1014,8 +1021,7 @@ type Event struct {
Message
string
`json:"message,omitempty"`
Message
string
`json:"message,omitempty"`
// Optional. The component reporting this event. Should be a short machine understandable string.
// Optional. The component reporting this event. Should be a short machine understandable string.
// TODO: provide exact specification for format.
Source
EventSource
`json:"source,omitempty"`
Source
string
`json:"source,omitempty"`
// The time at which the client recorded the event. (Time of server receipt is in TypeMeta.)
// The time at which the client recorded the event. (Time of server receipt is in TypeMeta.)
Timestamp
util
.
Time
`json:"timestamp,omitempty"`
Timestamp
util
.
Time
`json:"timestamp,omitempty"`
...
...
pkg/api/v1beta1/conversion.go
View file @
f11f0de4
...
@@ -548,7 +548,9 @@ func init() {
...
@@ -548,7 +548,9 @@ func init() {
return
nil
return
nil
},
},
// Event Status -> Condition
// Event Status <-> Condition
// Event Source <-> Source.Component
// Event Host <-> Source.Host
// TODO: remove this when it becomes possible to specify a field name conversion on a specific type
// TODO: remove this when it becomes possible to specify a field name conversion on a specific type
func
(
in
*
newer
.
Event
,
out
*
Event
,
s
conversion
.
Scope
)
error
{
func
(
in
*
newer
.
Event
,
out
*
Event
,
s
conversion
.
Scope
)
error
{
if
err
:=
s
.
Convert
(
&
in
.
TypeMeta
,
&
out
.
TypeMeta
,
0
);
err
!=
nil
{
if
err
:=
s
.
Convert
(
&
in
.
TypeMeta
,
&
out
.
TypeMeta
,
0
);
err
!=
nil
{
...
@@ -560,7 +562,8 @@ func init() {
...
@@ -560,7 +562,8 @@ func init() {
out
.
Status
=
in
.
Condition
out
.
Status
=
in
.
Condition
out
.
Reason
=
in
.
Reason
out
.
Reason
=
in
.
Reason
out
.
Message
=
in
.
Message
out
.
Message
=
in
.
Message
out
.
Source
=
in
.
Source
out
.
Source
=
in
.
Source
.
Component
out
.
Host
=
in
.
Source
.
Host
out
.
Timestamp
=
in
.
Timestamp
out
.
Timestamp
=
in
.
Timestamp
return
s
.
Convert
(
&
in
.
InvolvedObject
,
&
out
.
InvolvedObject
,
0
)
return
s
.
Convert
(
&
in
.
InvolvedObject
,
&
out
.
InvolvedObject
,
0
)
},
},
...
@@ -574,7 +577,8 @@ func init() {
...
@@ -574,7 +577,8 @@ func init() {
out
.
Condition
=
in
.
Status
out
.
Condition
=
in
.
Status
out
.
Reason
=
in
.
Reason
out
.
Reason
=
in
.
Reason
out
.
Message
=
in
.
Message
out
.
Message
=
in
.
Message
out
.
Source
=
in
.
Source
out
.
Source
.
Component
=
in
.
Source
out
.
Source
.
Host
=
in
.
Host
out
.
Timestamp
=
in
.
Timestamp
out
.
Timestamp
=
in
.
Timestamp
return
s
.
Convert
(
&
in
.
InvolvedObject
,
&
out
.
InvolvedObject
,
0
)
return
s
.
Convert
(
&
in
.
InvolvedObject
,
&
out
.
InvolvedObject
,
0
)
},
},
...
...
pkg/api/v1beta1/types.go
View file @
f11f0de4
...
@@ -817,6 +817,8 @@ type Event struct {
...
@@ -817,6 +817,8 @@ type Event struct {
// Optional. The component reporting this event. Should be a short machine understandable string.
// Optional. The component reporting this event. Should be a short machine understandable string.
// TODO: provide exact specification for format.
// TODO: provide exact specification for format.
Source
string
`json:"source,omitempty" description:"component reporting this event; short machine understandable string"`
Source
string
`json:"source,omitempty" description:"component reporting this event; short machine understandable string"`
// Host name on which the event is generated.
Host
string
`json:"host,omitempty"`
// The time at which the client recorded the event. (Time of server receipt is in TypeMeta.)
// The time at which the client recorded the event. (Time of server receipt is in TypeMeta.)
Timestamp
util
.
Time
`json:"timestamp,omitempty" description:"time at which the client recorded the event"`
Timestamp
util
.
Time
`json:"timestamp,omitempty" description:"time at which the client recorded the event"`
...
...
pkg/api/v1beta2/conversion.go
View file @
f11f0de4
...
@@ -464,7 +464,9 @@ func init() {
...
@@ -464,7 +464,9 @@ func init() {
return
nil
return
nil
},
},
// Event Status -> Condition
// Event Status <-> Condition
// Event Source <-> Source.Component
// Event Host <-> Source.Host
// TODO: remove this when it becomes possible to specify a field name conversion on a specific type
// TODO: remove this when it becomes possible to specify a field name conversion on a specific type
func
(
in
*
newer
.
Event
,
out
*
Event
,
s
conversion
.
Scope
)
error
{
func
(
in
*
newer
.
Event
,
out
*
Event
,
s
conversion
.
Scope
)
error
{
if
err
:=
s
.
Convert
(
&
in
.
TypeMeta
,
&
out
.
TypeMeta
,
0
);
err
!=
nil
{
if
err
:=
s
.
Convert
(
&
in
.
TypeMeta
,
&
out
.
TypeMeta
,
0
);
err
!=
nil
{
...
@@ -476,7 +478,8 @@ func init() {
...
@@ -476,7 +478,8 @@ func init() {
out
.
Status
=
in
.
Condition
out
.
Status
=
in
.
Condition
out
.
Reason
=
in
.
Reason
out
.
Reason
=
in
.
Reason
out
.
Message
=
in
.
Message
out
.
Message
=
in
.
Message
out
.
Source
=
in
.
Source
out
.
Source
=
in
.
Source
.
Component
out
.
Host
=
in
.
Source
.
Host
out
.
Timestamp
=
in
.
Timestamp
out
.
Timestamp
=
in
.
Timestamp
return
s
.
Convert
(
&
in
.
InvolvedObject
,
&
out
.
InvolvedObject
,
0
)
return
s
.
Convert
(
&
in
.
InvolvedObject
,
&
out
.
InvolvedObject
,
0
)
},
},
...
@@ -490,7 +493,8 @@ func init() {
...
@@ -490,7 +493,8 @@ func init() {
out
.
Condition
=
in
.
Status
out
.
Condition
=
in
.
Status
out
.
Reason
=
in
.
Reason
out
.
Reason
=
in
.
Reason
out
.
Message
=
in
.
Message
out
.
Message
=
in
.
Message
out
.
Source
=
in
.
Source
out
.
Source
.
Component
=
in
.
Source
out
.
Source
.
Host
=
in
.
Host
out
.
Timestamp
=
in
.
Timestamp
out
.
Timestamp
=
in
.
Timestamp
return
s
.
Convert
(
&
in
.
InvolvedObject
,
&
out
.
InvolvedObject
,
0
)
return
s
.
Convert
(
&
in
.
InvolvedObject
,
&
out
.
InvolvedObject
,
0
)
},
},
...
...
pkg/api/v1beta2/types.go
View file @
f11f0de4
...
@@ -791,6 +791,9 @@ type Event struct {
...
@@ -791,6 +791,9 @@ type Event struct {
// TODO: provide exact specification for format.
// TODO: provide exact specification for format.
Source
string
`json:"source,omitempty" description:"component reporting this event; short machine understandable string"`
Source
string
`json:"source,omitempty" description:"component reporting this event; short machine understandable string"`
// Host name on which the event is generated.
Host
string
`json:"host,omitempty"`
// The time at which the client recorded the event. (Time of server receipt is in TypeMeta.)
// The time at which the client recorded the event. (Time of server receipt is in TypeMeta.)
Timestamp
util
.
Time
`json:"timestamp,omitempty" description:"time at which the client recorded the event"`
Timestamp
util
.
Time
`json:"timestamp,omitempty" description:"time at which the client recorded the event"`
}
}
...
...
pkg/api/v1beta3/types.go
View file @
f11f0de4
...
@@ -1003,6 +1003,13 @@ type ObjectReference struct {
...
@@ -1003,6 +1003,13 @@ type ObjectReference struct {
FieldPath
string
`json:"fieldPath,omitempty"`
FieldPath
string
`json:"fieldPath,omitempty"`
}
}
type
EventSource
struct
{
// Component from which the event is generated.
Component
string
`json:"component,omitempty"`
// Host name on which the event is generated.
Host
string
`json:"host,omitempty"`
}
// Event is a report of an event somewhere in the cluster.
// Event is a report of an event somewhere in the cluster.
// TODO: Decide whether to store these separately or with the object they apply to.
// TODO: Decide whether to store these separately or with the object they apply to.
type
Event
struct
{
type
Event
struct
{
...
@@ -1032,8 +1039,7 @@ type Event struct {
...
@@ -1032,8 +1039,7 @@ type Event struct {
Message
string
`json:"message,omitempty"`
Message
string
`json:"message,omitempty"`
// Optional. The component reporting this event. Should be a short machine understandable string.
// Optional. The component reporting this event. Should be a short machine understandable string.
// TODO: provide exact specification for format.
Source
EventSource
`json:"source,omitempty"`
Source
string
`json:"source,omitempty"`
// The time at which the client recorded the event. (Time of server receipt is in TypeMeta.)
// The time at which the client recorded the event. (Time of server receipt is in TypeMeta.)
Timestamp
util
.
Time
`json:"timestamp,omitempty"`
Timestamp
util
.
Time
`json:"timestamp,omitempty"`
...
...
pkg/client/record/event.go
View file @
f11f0de4
...
@@ -41,13 +41,13 @@ type EventRecorder interface {
...
@@ -41,13 +41,13 @@ type EventRecorder interface {
// StartRecording starts sending events to recorder. Call once while initializing
// StartRecording starts sending events to recorder. Call once while initializing
// your binary. Subsequent calls will be ignored. The return value can be ignored
// your binary. Subsequent calls will be ignored. The return value can be ignored
// or used to stop recording, if desired.
// or used to stop recording, if desired.
func
StartRecording
(
recorder
EventRecorder
,
source
Name
string
)
watch
.
Interface
{
func
StartRecording
(
recorder
EventRecorder
,
source
api
.
EventSource
)
watch
.
Interface
{
return
GetEvents
(
func
(
event
*
api
.
Event
)
{
return
GetEvents
(
func
(
event
*
api
.
Event
)
{
// Make a copy before modification, because there could be multiple listeners.
// Make a copy before modification, because there could be multiple listeners.
// Events are safe to copy like this.
// Events are safe to copy like this.
eventCopy
:=
*
event
eventCopy
:=
*
event
event
=
&
eventCopy
event
=
&
eventCopy
event
.
Source
=
source
Name
event
.
Source
=
source
try
:=
0
try
:=
0
for
{
for
{
try
++
try
++
...
...
pkg/client/record/event_test.go
View file @
f11f0de4
...
@@ -89,7 +89,7 @@ func TestEventf(t *testing.T) {
...
@@ -89,7 +89,7 @@ func TestEventf(t *testing.T) {
Condition
:
"Running"
,
Condition
:
"Running"
,
Reason
:
"Started"
,
Reason
:
"Started"
,
Message
:
"some verbose message: 1"
,
Message
:
"some verbose message: 1"
,
Source
:
"eventTest"
,
Source
:
api
.
EventSource
{
Component
:
"eventTest"
}
,
},
},
expectLog
:
`Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1beta1", ResourceVersion:"", FieldPath:"desiredState.manifest.containers[2]"}): status: 'Running', reason: 'Started' some verbose message: 1`
,
expectLog
:
`Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1beta1", ResourceVersion:"", FieldPath:"desiredState.manifest.containers[2]"}): status: 'Running', reason: 'Started' some verbose message: 1`
,
},
},
...
@@ -114,7 +114,7 @@ func TestEventf(t *testing.T) {
...
@@ -114,7 +114,7 @@ func TestEventf(t *testing.T) {
Condition
:
"Running"
,
Condition
:
"Running"
,
Reason
:
"Started"
,
Reason
:
"Started"
,
Message
:
"some verbose message: 1"
,
Message
:
"some verbose message: 1"
,
Source
:
"eventTest"
,
Source
:
api
.
EventSource
{
Component
:
"eventTest"
}
,
},
},
expectLog
:
`Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1beta1", ResourceVersion:"", FieldPath:""}): status: 'Running', reason: 'Started' some verbose message: 1`
,
expectLog
:
`Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1beta1", ResourceVersion:"", FieldPath:""}): status: 'Running', reason: 'Started' some verbose message: 1`
,
},
},
...
@@ -142,7 +142,7 @@ func TestEventf(t *testing.T) {
...
@@ -142,7 +142,7 @@ func TestEventf(t *testing.T) {
return
event
,
nil
return
event
,
nil
},
},
}
}
recorder
:=
record
.
StartRecording
(
&
testEvents
,
"eventTest"
)
recorder
:=
record
.
StartRecording
(
&
testEvents
,
api
.
EventSource
{
Component
:
"eventTest"
}
)
logger
:=
record
.
StartLogging
(
t
.
Logf
)
// Prove that it is useful
logger
:=
record
.
StartLogging
(
t
.
Logf
)
// Prove that it is useful
logger2
:=
record
.
StartLogging
(
func
(
formatter
string
,
args
...
interface
{})
{
logger2
:=
record
.
StartLogging
(
func
(
formatter
string
,
args
...
interface
{})
{
if
e
,
a
:=
item
.
expectLog
,
fmt
.
Sprintf
(
formatter
,
args
...
);
e
!=
a
{
if
e
,
a
:=
item
.
expectLog
,
fmt
.
Sprintf
(
formatter
,
args
...
);
e
!=
a
{
...
@@ -223,7 +223,7 @@ func TestWriteEventError(t *testing.T) {
...
@@ -223,7 +223,7 @@ func TestWriteEventError(t *testing.T) {
return
event
,
nil
return
event
,
nil
},
},
},
},
"eventTest"
,
api
.
EventSource
{
Component
:
"eventTest"
}
,
)
.
Stop
()
)
.
Stop
()
for
caseName
:=
range
table
{
for
caseName
:=
range
table
{
...
...
pkg/kubectl/describe_test.go
View file @
f11f0de4
...
@@ -69,17 +69,17 @@ func TestPodDescribeResultsSorted(t *testing.T) {
...
@@ -69,17 +69,17 @@ func TestPodDescribeResultsSorted(t *testing.T) {
EventsList
:
api
.
EventList
{
EventsList
:
api
.
EventList
{
Items
:
[]
api
.
Event
{
Items
:
[]
api
.
Event
{
{
{
Source
:
"kubelet"
,
Source
:
api
.
EventSource
{
Component
:
"kubelet"
}
,
Message
:
"Item 1"
,
Message
:
"Item 1"
,
Timestamp
:
util
.
NewTime
(
time
.
Date
(
2014
,
time
.
January
,
15
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Timestamp
:
util
.
NewTime
(
time
.
Date
(
2014
,
time
.
January
,
15
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
},
},
{
{
Source
:
"scheduler"
,
Source
:
api
.
EventSource
{
Component
:
"scheduler"
}
,
Message
:
"Item 2"
,
Message
:
"Item 2"
,
Timestamp
:
util
.
NewTime
(
time
.
Date
(
1987
,
time
.
June
,
17
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Timestamp
:
util
.
NewTime
(
time
.
Date
(
1987
,
time
.
June
,
17
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
},
},
{
{
Source
:
"kubelet"
,
Source
:
api
.
EventSource
{
Component
:
"kubelet"
}
,
Message
:
"Item 3"
,
Message
:
"Item 3"
,
Timestamp
:
util
.
NewTime
(
time
.
Date
(
2002
,
time
.
December
,
25
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Timestamp
:
util
.
NewTime
(
time
.
Date
(
2002
,
time
.
December
,
25
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
},
},
...
...
pkg/kubectl/resource_printer.go
View file @
f11f0de4
...
@@ -193,7 +193,7 @@ var replicationControllerColumns = []string{"CONTROLLER", "CONTAINER(S)", "IMAGE
...
@@ -193,7 +193,7 @@ var replicationControllerColumns = []string{"CONTROLLER", "CONTAINER(S)", "IMAGE
var
serviceColumns
=
[]
string
{
"NAME"
,
"LABELS"
,
"SELECTOR"
,
"IP"
,
"PORT"
}
var
serviceColumns
=
[]
string
{
"NAME"
,
"LABELS"
,
"SELECTOR"
,
"IP"
,
"PORT"
}
var
minionColumns
=
[]
string
{
"NAME"
,
"LABELS"
}
var
minionColumns
=
[]
string
{
"NAME"
,
"LABELS"
}
var
statusColumns
=
[]
string
{
"STATUS"
}
var
statusColumns
=
[]
string
{
"STATUS"
}
var
eventColumns
=
[]
string
{
"TIME"
,
"NAME"
,
"KIND"
,
"SUBOBJECT"
,
"CONDITION"
,
"REASON"
,
"MESSAGE"
}
var
eventColumns
=
[]
string
{
"TIME"
,
"NAME"
,
"KIND"
,
"SUBOBJECT"
,
"CONDITION"
,
"REASON"
,
"
SOURCE"
,
"
MESSAGE"
}
// addDefaultHandlers adds print handlers for default Kubernetes types.
// addDefaultHandlers adds print handlers for default Kubernetes types.
func
(
h
*
HumanReadablePrinter
)
addDefaultHandlers
()
{
func
(
h
*
HumanReadablePrinter
)
addDefaultHandlers
()
{
...
@@ -339,13 +339,14 @@ func printStatus(status *api.Status, w io.Writer) error {
...
@@ -339,13 +339,14 @@ func printStatus(status *api.Status, w io.Writer) error {
func
printEvent
(
event
*
api
.
Event
,
w
io
.
Writer
)
error
{
func
printEvent
(
event
*
api
.
Event
,
w
io
.
Writer
)
error
{
_
,
err
:=
fmt
.
Fprintf
(
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\t
%s
\t
%s
\t
%s
\t
%s
\t
%s
\n
"
,
w
,
"%s
\t
%s
\t
%s
\t
%s
\t
%s
\t
%s
\t
%s
\
t
%s
\
n
"
,
event
.
Timestamp
.
Time
.
Format
(
time
.
RFC1123Z
),
event
.
Timestamp
.
Time
.
Format
(
time
.
RFC1123Z
),
event
.
InvolvedObject
.
Name
,
event
.
InvolvedObject
.
Name
,
event
.
InvolvedObject
.
Kind
,
event
.
InvolvedObject
.
Kind
,
event
.
InvolvedObject
.
FieldPath
,
event
.
InvolvedObject
.
FieldPath
,
event
.
Condition
,
event
.
Condition
,
event
.
Reason
,
event
.
Reason
,
event
.
Source
,
event
.
Message
,
event
.
Message
,
)
)
return
err
return
err
...
...
pkg/kubectl/resource_printer_test.go
View file @
f11f0de4
...
@@ -463,17 +463,17 @@ func TestPrintEventsResultSorted(t *testing.T) {
...
@@ -463,17 +463,17 @@ func TestPrintEventsResultSorted(t *testing.T) {
obj
:=
api
.
EventList
{
obj
:=
api
.
EventList
{
Items
:
[]
api
.
Event
{
Items
:
[]
api
.
Event
{
{
{
Source
:
"kubelet"
,
Source
:
api
.
EventSource
{
Component
:
"kubelet"
}
,
Message
:
"Item 1"
,
Message
:
"Item 1"
,
Timestamp
:
util
.
NewTime
(
time
.
Date
(
2014
,
time
.
January
,
15
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Timestamp
:
util
.
NewTime
(
time
.
Date
(
2014
,
time
.
January
,
15
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
},
},
{
{
Source
:
"scheduler"
,
Source
:
api
.
EventSource
{
Component
:
"scheduler"
}
,
Message
:
"Item 2"
,
Message
:
"Item 2"
,
Timestamp
:
util
.
NewTime
(
time
.
Date
(
1987
,
time
.
June
,
17
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Timestamp
:
util
.
NewTime
(
time
.
Date
(
1987
,
time
.
June
,
17
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
},
},
{
{
Source
:
"kubelet"
,
Source
:
api
.
EventSource
{
Component
:
"kubelet"
}
,
Message
:
"Item 3"
,
Message
:
"Item 3"
,
Timestamp
:
util
.
NewTime
(
time
.
Date
(
2002
,
time
.
December
,
25
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Timestamp
:
util
.
NewTime
(
time
.
Date
(
2002
,
time
.
December
,
25
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
},
},
...
...
pkg/kubectl/sorted_event_list_test.go
View file @
f11f0de4
...
@@ -54,17 +54,17 @@ func TestSortableEvents(t *testing.T) {
...
@@ -54,17 +54,17 @@ func TestSortableEvents(t *testing.T) {
// Arrange
// Arrange
list
:=
SortableEvents
([]
api
.
Event
{
list
:=
SortableEvents
([]
api
.
Event
{
{
{
Source
:
"kubelet"
,
Source
:
api
.
EventSource
{
Component
:
"kubelet"
}
,
Message
:
"Item 1"
,
Message
:
"Item 1"
,
Timestamp
:
util
.
NewTime
(
time
.
Date
(
2014
,
time
.
January
,
15
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Timestamp
:
util
.
NewTime
(
time
.
Date
(
2014
,
time
.
January
,
15
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
},
},
{
{
Source
:
"scheduler"
,
Source
:
api
.
EventSource
{
Component
:
"scheduler"
}
,
Message
:
"Item 2"
,
Message
:
"Item 2"
,
Timestamp
:
util
.
NewTime
(
time
.
Date
(
1987
,
time
.
June
,
17
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Timestamp
:
util
.
NewTime
(
time
.
Date
(
1987
,
time
.
June
,
17
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
},
},
{
{
Source
:
"kubelet"
,
Source
:
api
.
EventSource
{
Component
:
"kubelet"
}
,
Message
:
"Item 3"
,
Message
:
"Item 3"
,
Timestamp
:
util
.
NewTime
(
time
.
Date
(
2002
,
time
.
December
,
25
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
Timestamp
:
util
.
NewTime
(
time
.
Date
(
2002
,
time
.
December
,
25
,
0
,
0
,
0
,
0
,
time
.
UTC
)),
},
},
...
...
pkg/kubelet/config/file.go
View file @
f11f0de4
...
@@ -159,6 +159,11 @@ func extractFromFile(filename string) (api.BoundPod, error) {
...
@@ -159,6 +159,11 @@ func extractFromFile(filename string) (api.BoundPod, error) {
if
len
(
pod
.
Namespace
)
==
0
{
if
len
(
pod
.
Namespace
)
==
0
{
pod
.
Namespace
=
api
.
NamespaceDefault
pod
.
Namespace
=
api
.
NamespaceDefault
}
}
// TODO(dchen1107): BoundPod is not type of runtime.Object. Once we allow kubelet talks
// about Pod directly, we can use SelfLinker defined in package: latest
// Currently just simply follow the same format in resthandler.go
pod
.
ObjectMeta
.
SelfLink
=
fmt
.
Sprintf
(
"/api/v1beta2/pods/%s?namespace=%s"
,
pod
.
Name
,
pod
.
Namespace
)
if
glog
.
V
(
4
)
{
if
glog
.
V
(
4
)
{
glog
.
Infof
(
"Got pod from file %q: %#v"
,
filename
,
pod
)
glog
.
Infof
(
"Got pod from file %q: %#v"
,
filename
,
pod
)
...
...
pkg/kubelet/config/file_test.go
View file @
f11f0de4
...
@@ -124,6 +124,7 @@ func TestReadFromFile(t *testing.T) {
...
@@ -124,6 +124,7 @@ func TestReadFromFile(t *testing.T) {
Name
:
"test"
,
Name
:
"test"
,
UID
:
simpleSubdomainSafeHash
(
file
.
Name
()),
UID
:
simpleSubdomainSafeHash
(
file
.
Name
()),
Namespace
:
"default"
,
Namespace
:
"default"
,
SelfLink
:
"/api/v1beta2/pods/test?namespace=default"
,
},
},
Spec
:
api
.
PodSpec
{
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{{
Image
:
"test/image"
,
TerminationMessagePath
:
"/dev/termination-log"
}},
Containers
:
[]
api
.
Container
{{
Image
:
"test/image"
,
TerminationMessagePath
:
"/dev/termination-log"
}},
...
@@ -161,6 +162,7 @@ func TestExtractFromValidDataFile(t *testing.T) {
...
@@ -161,6 +162,7 @@ func TestExtractFromValidDataFile(t *testing.T) {
file
:=
writeTestFile
(
t
,
os
.
TempDir
(),
"test_pod_config"
,
string
(
text
))
file
:=
writeTestFile
(
t
,
os
.
TempDir
(),
"test_pod_config"
,
string
(
text
))
defer
os
.
Remove
(
file
.
Name
())
defer
os
.
Remove
(
file
.
Name
())
expectedPod
.
ObjectMeta
.
SelfLink
=
"/api/v1beta2/pods/"
+
expectedPod
.
Name
+
"?namespace=default"
ch
:=
make
(
chan
interface
{},
1
)
ch
:=
make
(
chan
interface
{},
1
)
c
:=
sourceFile
{
file
.
Name
(),
ch
}
c
:=
sourceFile
{
file
.
Name
(),
ch
}
err
=
c
.
extractFromPath
()
err
=
c
.
extractFromPath
()
...
@@ -226,6 +228,7 @@ func TestExtractFromDir(t *testing.T) {
...
@@ -226,6 +228,7 @@ func TestExtractFromDir(t *testing.T) {
}
}
ioutil
.
WriteFile
(
name
,
data
,
0755
)
ioutil
.
WriteFile
(
name
,
data
,
0755
)
files
[
i
]
=
file
files
[
i
]
=
file
pods
[
i
]
.
ObjectMeta
.
SelfLink
=
"/api/v1beta2/pods/"
+
pods
[
i
]
.
Name
+
"?namespace=default"
}
}
ch
:=
make
(
chan
interface
{},
1
)
ch
:=
make
(
chan
interface
{},
1
)
...
...
pkg/kubelet/util.go
View file @
f11f0de4
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"path"
"path"
"strconv"
"strconv"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/capabilities"
"github.com/GoogleCloudPlatform/kubernetes/pkg/capabilities"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
...
@@ -130,8 +131,13 @@ func SetupEventSending(authPath string, apiServerList util.StringList) {
...
@@ -130,8 +131,13 @@ func SetupEventSending(authPath string, apiServerList util.StringList) {
glog
.
Errorf
(
"Unable to make apiserver client: %v"
,
err
)
glog
.
Errorf
(
"Unable to make apiserver client: %v"
,
err
)
}
else
{
}
else
{
// Send events to APIserver if there is a client.
// Send events to APIserver if there is a client.
hostname
:=
util
.
GetHostname
(
""
)
glog
.
Infof
(
"Sending events to APIserver."
)
glog
.
Infof
(
"Sending events to APIserver."
)
record
.
StartRecording
(
apiClient
.
Events
(
""
),
"kubelet"
)
record
.
StartRecording
(
apiClient
.
Events
(
""
),
api
.
EventSource
{
Component
:
"kubelet"
,
Host
:
hostname
,
})
}
}
}
}
}
}
pkg/registry/event/rest.go
View file @
f11f0de4
...
@@ -109,7 +109,7 @@ func (rs *REST) getAttrs(obj runtime.Object) (objLabels, objFields labels.Set, e
...
@@ -109,7 +109,7 @@ func (rs *REST) getAttrs(obj runtime.Object) (objLabels, objFields labels.Set, e
"condition"
:
event
.
Condition
,
"condition"
:
event
.
Condition
,
"status"
:
event
.
Condition
,
// TODO: remove me when we version fields
"status"
:
event
.
Condition
,
// TODO: remove me when we version fields
"reason"
:
event
.
Reason
,
"reason"
:
event
.
Reason
,
"source"
:
event
.
Source
,
"source"
:
event
.
Source
.
Component
,
},
nil
},
nil
}
}
...
...
pkg/registry/event/rest_test.go
View file @
f11f0de4
...
@@ -145,7 +145,7 @@ func TestRESTgetAttrs(t *testing.T) {
...
@@ -145,7 +145,7 @@ func TestRESTgetAttrs(t *testing.T) {
},
},
Condition
:
"Tested"
,
Condition
:
"Tested"
,
Reason
:
"ForTesting"
,
Reason
:
"ForTesting"
,
Source
:
"test"
,
Source
:
api
.
EventSource
{
Component
:
"test"
}
,
}
}
label
,
field
,
err
:=
rest
.
getAttrs
(
eventA
)
label
,
field
,
err
:=
rest
.
getAttrs
(
eventA
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
plugin/cmd/kube-scheduler/scheduler.go
View file @
f11f0de4
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"net/http"
"net/http"
"strconv"
"strconv"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
_
"github.com/GoogleCloudPlatform/kubernetes/pkg/healthz"
_
"github.com/GoogleCloudPlatform/kubernetes/pkg/healthz"
...
@@ -57,7 +58,7 @@ func main() {
...
@@ -57,7 +58,7 @@ func main() {
glog
.
Fatalf
(
"Invalid API configuration: %v"
,
err
)
glog
.
Fatalf
(
"Invalid API configuration: %v"
,
err
)
}
}
record
.
StartRecording
(
kubeClient
.
Events
(
""
),
"scheduler"
)
record
.
StartRecording
(
kubeClient
.
Events
(
""
),
api
.
EventSource
{
Component
:
"scheduler"
}
)
go
http
.
ListenAndServe
(
net
.
JoinHostPort
(
address
.
String
(),
strconv
.
Itoa
(
*
port
)),
nil
)
go
http
.
ListenAndServe
(
net
.
JoinHostPort
(
address
.
String
(),
strconv
.
Itoa
(
*
port
)),
nil
)
...
...
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