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
6b428ef1
Commit
6b428ef1
authored
May 21, 2015
by
David Oppenheimer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7170 from simon3z/node-events
Node events recording fixes
parents
9b1fb6dc
fefc6516
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
37 deletions
+28
-37
nodecontroller.go
pkg/cloudprovider/nodecontroller/nodecontroller.go
+4
-10
kubelet.go
pkg/kubelet/kubelet.go
+24
-27
No files found.
pkg/cloudprovider/nodecontroller/nodecontroller.go
View file @
6b428ef1
...
@@ -424,7 +424,7 @@ func (nc *NodeController) recordNodeEvent(node *api.Node, event string) {
...
@@ -424,7 +424,7 @@ func (nc *NodeController) recordNodeEvent(node *api.Node, event string) {
glog
.
V
(
2
)
.
Infof
(
"Recording %s event message for node %s"
,
event
,
node
.
Name
)
glog
.
V
(
2
)
.
Infof
(
"Recording %s event message for node %s"
,
event
,
node
.
Name
)
// TODO: This requires a transaction, either both node status is updated
// TODO: This requires a transaction, either both node status is updated
// and event is recorded or neither should happen, see issue #6055.
// and event is recorded or neither should happen, see issue #6055.
nc
.
recorder
.
Eventf
(
ref
,
event
,
"Node %s
is now
%s"
,
node
.
Name
,
event
)
nc
.
recorder
.
Eventf
(
ref
,
event
,
"Node %s
status is now:
%s"
,
node
.
Name
,
event
)
}
}
// For a given node checks its conditions and tries to update it. Returns grace period to which given node
// For a given node checks its conditions and tries to update it. Returns grace period to which given node
...
@@ -611,15 +611,9 @@ func (nc *NodeController) monitorNodeStatus() error {
...
@@ -611,15 +611,9 @@ func (nc *NodeController) monitorNodeStatus() error {
}
}
}
}
// Report node events.
// Report node event.
if
readyCondition
.
Status
==
api
.
ConditionTrue
&&
lastReadyCondition
.
Status
!=
api
.
ConditionTrue
{
if
readyCondition
.
Status
!=
api
.
ConditionTrue
&&
lastReadyCondition
.
Status
==
api
.
ConditionTrue
{
nc
.
recordNodeEvent
(
node
,
"ready"
)
nc
.
recordNodeEvent
(
node
,
"NodeNotReady"
)
}
if
readyCondition
.
Status
==
api
.
ConditionFalse
&&
lastReadyCondition
.
Status
!=
api
.
ConditionFalse
{
nc
.
recordNodeEvent
(
node
,
"not_ready"
)
}
if
readyCondition
.
Status
==
api
.
ConditionUnknown
&&
lastReadyCondition
.
Status
!=
api
.
ConditionUnknown
{
nc
.
recordNodeEvent
(
node
,
"unknown"
)
}
}
}
}
}
}
...
...
pkg/kubelet/kubelet.go
View file @
6b428ef1
...
@@ -1716,22 +1716,11 @@ func (kl *Kubelet) updateNodeStatus() error {
...
@@ -1716,22 +1716,11 @@ func (kl *Kubelet) updateNodeStatus() error {
return
fmt
.
Errorf
(
"Update node status exceeds retry count"
)
return
fmt
.
Errorf
(
"Update node status exceeds retry count"
)
}
}
func
(
kl
*
Kubelet
)
recordNodeOnlineEvent
()
{
func
(
kl
*
Kubelet
)
recordNodeStatusEvent
(
event
string
)
{
glog
.
V
(
2
)
.
Infof
(
"Recording %s event message for node %s"
,
event
,
kl
.
hostname
)
// TODO: This requires a transaction, either both node status is updated
// TODO: This requires a transaction, either both node status is updated
// and event is recorded or neither should happen, see issue #6055.
// and event is recorded or neither should happen, see issue #6055.
kl
.
recorder
.
Eventf
(
kl
.
nodeRef
,
"online"
,
"Node %s is now online"
,
kl
.
hostname
)
kl
.
recorder
.
Eventf
(
kl
.
nodeRef
,
event
,
"Node %s status is now: %s"
,
kl
.
hostname
,
event
)
}
func
(
kl
*
Kubelet
)
recordNodeSchedulableEvent
()
{
// TODO: This requires a transaction, either both node status is updated
// and event is recorded or neither should happen, see issue #6055.
kl
.
recorder
.
Eventf
(
kl
.
nodeRef
,
"schedulable"
,
"Node %s is now schedulable"
,
kl
.
hostname
)
}
func
(
kl
*
Kubelet
)
recordNodeUnschedulableEvent
()
{
// TODO: This requires a transaction, either both node status is updated
// and event is recorded or neither should happen, see issue #6055.
kl
.
recorder
.
Eventf
(
kl
.
nodeRef
,
"unschedulable"
,
"Node %s is now unschedulable"
,
kl
.
hostname
)
}
}
// Maintains Node.Spec.Unschedulable value from previous run of tryUpdateNodeStatus()
// Maintains Node.Spec.Unschedulable value from previous run of tryUpdateNodeStatus()
...
@@ -1798,9 +1787,10 @@ func (kl *Kubelet) tryUpdateNodeStatus() error {
...
@@ -1798,9 +1787,10 @@ func (kl *Kubelet) tryUpdateNodeStatus() error {
}()
}()
currentTime
:=
util
.
Now
()
currentTime
:=
util
.
Now
()
var
newCondition
api
.
NodeCondition
var
newNodeReadyCondition
api
.
NodeCondition
var
oldNodeReadyConditionStatus
api
.
ConditionStatus
if
containerRuntimeUp
&&
networkConfigured
{
if
containerRuntimeUp
&&
networkConfigured
{
newCondition
=
api
.
NodeCondition
{
new
NodeReady
Condition
=
api
.
NodeCondition
{
Type
:
api
.
NodeReady
,
Type
:
api
.
NodeReady
,
Status
:
api
.
ConditionTrue
,
Status
:
api
.
ConditionTrue
,
Reason
:
"kubelet is posting ready status"
,
Reason
:
"kubelet is posting ready status"
,
...
@@ -1814,7 +1804,7 @@ func (kl *Kubelet) tryUpdateNodeStatus() error {
...
@@ -1814,7 +1804,7 @@ func (kl *Kubelet) tryUpdateNodeStatus() error {
if
!
networkConfigured
{
if
!
networkConfigured
{
reasons
=
append
(
reasons
,
"network not configured correctly"
)
reasons
=
append
(
reasons
,
"network not configured correctly"
)
}
}
newCondition
=
api
.
NodeCondition
{
new
NodeReady
Condition
=
api
.
NodeCondition
{
Type
:
api
.
NodeReady
,
Type
:
api
.
NodeReady
,
Status
:
api
.
ConditionFalse
,
Status
:
api
.
ConditionFalse
,
Reason
:
strings
.
Join
(
reasons
,
","
),
Reason
:
strings
.
Join
(
reasons
,
","
),
...
@@ -1825,25 +1815,32 @@ func (kl *Kubelet) tryUpdateNodeStatus() error {
...
@@ -1825,25 +1815,32 @@ func (kl *Kubelet) tryUpdateNodeStatus() error {
updated
:=
false
updated
:=
false
for
i
:=
range
node
.
Status
.
Conditions
{
for
i
:=
range
node
.
Status
.
Conditions
{
if
node
.
Status
.
Conditions
[
i
]
.
Type
==
api
.
NodeReady
{
if
node
.
Status
.
Conditions
[
i
]
.
Type
==
api
.
NodeReady
{
newCondition
.
LastTransitionTime
=
node
.
Status
.
Conditions
[
i
]
.
LastTransitionTime
oldNodeReadyConditionStatus
=
node
.
Status
.
Conditions
[
i
]
.
Status
if
node
.
Status
.
Conditions
[
i
]
.
Status
!=
api
.
ConditionTrue
{
if
oldNodeReadyConditionStatus
==
newNodeReadyCondition
.
Status
{
kl
.
recordNodeOnlineEvent
()
newNodeReadyCondition
.
LastTransitionTime
=
node
.
Status
.
Conditions
[
i
]
.
LastTransitionTime
}
else
{
newNodeReadyCondition
.
LastTransitionTime
=
currentTime
}
}
node
.
Status
.
Conditions
[
i
]
=
newCondition
node
.
Status
.
Conditions
[
i
]
=
new
NodeReady
Condition
updated
=
true
updated
=
true
}
}
}
}
if
!
updated
{
if
!
updated
{
newCondition
.
LastTransitionTime
=
currentTime
newNodeReadyCondition
.
LastTransitionTime
=
currentTime
node
.
Status
.
Conditions
=
append
(
node
.
Status
.
Conditions
,
newCondition
)
node
.
Status
.
Conditions
=
append
(
node
.
Status
.
Conditions
,
newNodeReadyCondition
)
kl
.
recordNodeOnlineEvent
()
}
if
!
updated
||
oldNodeReadyConditionStatus
!=
newNodeReadyCondition
.
Status
{
if
newNodeReadyCondition
.
Status
==
api
.
ConditionTrue
{
kl
.
recordNodeStatusEvent
(
"NodeReady"
)
}
else
{
kl
.
recordNodeStatusEvent
(
"NodeNotReady"
)
}
}
}
if
oldNodeUnschedulable
!=
node
.
Spec
.
Unschedulable
{
if
oldNodeUnschedulable
!=
node
.
Spec
.
Unschedulable
{
if
node
.
Spec
.
Unschedulable
{
if
node
.
Spec
.
Unschedulable
{
kl
.
recordNode
UnschedulableEvent
(
)
kl
.
recordNode
StatusEvent
(
"NodeNotSchedulable"
)
}
else
{
}
else
{
kl
.
recordNodeS
chedulableEvent
(
)
kl
.
recordNodeS
tatusEvent
(
"NodeSchedulable"
)
}
}
oldNodeUnschedulable
=
node
.
Spec
.
Unschedulable
oldNodeUnschedulable
=
node
.
Spec
.
Unschedulable
}
}
...
...
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