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
8a518099
Commit
8a518099
authored
Jul 31, 2017
by
David Ashpole
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set nodeOODCondition
parent
4a73f19a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
0 deletions
+64
-0
kubelet_node_status.go
pkg/kubelet/kubelet_node_status.go
+32
-0
kubelet_node_status_test.go
pkg/kubelet/kubelet_node_status_test.go
+32
-0
No files found.
pkg/kubelet/kubelet_node_status.go
View file @
8a518099
...
...
@@ -852,6 +852,37 @@ func (kl *Kubelet) setNodeDiskPressureCondition(node *v1.Node) {
}
}
// Set OODCondition for the node.
func
(
kl
*
Kubelet
)
setNodeOODCondition
(
node
*
v1
.
Node
)
{
currentTime
:=
metav1
.
NewTime
(
kl
.
clock
.
Now
())
var
nodeOODCondition
*
v1
.
NodeCondition
// Check if NodeOutOfDisk condition already exists and if it does, just pick it up for update.
for
i
:=
range
node
.
Status
.
Conditions
{
if
node
.
Status
.
Conditions
[
i
]
.
Type
==
v1
.
NodeOutOfDisk
{
nodeOODCondition
=
&
node
.
Status
.
Conditions
[
i
]
}
}
newOODCondition
:=
nodeOODCondition
==
nil
if
newOODCondition
||
nodeOODCondition
.
Status
==
v1
.
ConditionUnknown
{
nodeOODCondition
=
&
v1
.
NodeCondition
{
Type
:
v1
.
NodeOutOfDisk
,
Status
:
v1
.
ConditionFalse
,
Reason
:
"KubeletHasSufficientDisk"
,
Message
:
"kubelet has sufficient disk space available"
,
LastTransitionTime
:
currentTime
,
}
}
// Update the heartbeat time irrespective of all the conditions.
nodeOODCondition
.
LastHeartbeatTime
=
currentTime
if
newOODCondition
{
node
.
Status
.
Conditions
=
append
(
node
.
Status
.
Conditions
,
*
nodeOODCondition
)
}
}
// Maintains Node.Spec.Unschedulable value from previous run of tryUpdateNodeStatus()
// TODO: why is this a package var?
var
oldNodeUnschedulable
bool
...
...
@@ -902,6 +933,7 @@ func (kl *Kubelet) defaultNodeStatusFuncs() []func(*v1.Node) error {
return
[]
func
(
*
v1
.
Node
)
error
{
kl
.
setNodeAddress
,
withoutError
(
kl
.
setNodeStatusInfo
),
withoutError
(
kl
.
setNodeOODCondition
),
withoutError
(
kl
.
setNodeMemoryPressureCondition
),
withoutError
(
kl
.
setNodeDiskPressureCondition
),
withoutError
(
kl
.
setNodeReadyCondition
),
...
...
pkg/kubelet/kubelet_node_status_test.go
View file @
8a518099
...
...
@@ -169,6 +169,14 @@ func TestUpdateNewNodeStatus(t *testing.T) {
Status
:
v1
.
NodeStatus
{
Conditions
:
[]
v1
.
NodeCondition
{
{
Type
:
v1
.
NodeOutOfDisk
,
Status
:
v1
.
ConditionFalse
,
Reason
:
"KubeletHasSufficientDisk"
,
Message
:
fmt
.
Sprintf
(
"kubelet has sufficient disk space available"
),
LastHeartbeatTime
:
metav1
.
Time
{},
LastTransitionTime
:
metav1
.
Time
{},
},
{
Type
:
v1
.
NodeMemoryPressure
,
Status
:
v1
.
ConditionFalse
,
Reason
:
"KubeletHasSufficientMemory"
,
...
...
@@ -268,6 +276,14 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
Status
:
v1
.
NodeStatus
{
Conditions
:
[]
v1
.
NodeCondition
{
{
Type
:
v1
.
NodeOutOfDisk
,
Status
:
v1
.
ConditionFalse
,
Reason
:
"KubeletHasSufficientDisk"
,
Message
:
fmt
.
Sprintf
(
"kubelet has sufficient disk space available"
),
LastHeartbeatTime
:
metav1
.
Date
(
2012
,
1
,
1
,
0
,
0
,
0
,
0
,
time
.
UTC
),
LastTransitionTime
:
metav1
.
Date
(
2012
,
1
,
1
,
0
,
0
,
0
,
0
,
time
.
UTC
),
},
{
Type
:
v1
.
NodeMemoryPressure
,
Status
:
v1
.
ConditionFalse
,
Reason
:
"KubeletHasSufficientMemory"
,
...
...
@@ -327,6 +343,14 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
Status
:
v1
.
NodeStatus
{
Conditions
:
[]
v1
.
NodeCondition
{
{
Type
:
v1
.
NodeOutOfDisk
,
Status
:
v1
.
ConditionFalse
,
Reason
:
"KubeletHasSufficientDisk"
,
Message
:
fmt
.
Sprintf
(
"kubelet has sufficient disk space available"
),
LastHeartbeatTime
:
metav1
.
Time
{},
LastTransitionTime
:
metav1
.
Time
{},
},
{
Type
:
v1
.
NodeMemoryPressure
,
Status
:
v1
.
ConditionFalse
,
Reason
:
"KubeletHasSufficientMemory"
,
...
...
@@ -461,6 +485,14 @@ func TestUpdateNodeStatusWithRuntimeStateError(t *testing.T) {
Status
:
v1
.
NodeStatus
{
Conditions
:
[]
v1
.
NodeCondition
{
{
Type
:
v1
.
NodeOutOfDisk
,
Status
:
v1
.
ConditionFalse
,
Reason
:
"KubeletHasSufficientDisk"
,
Message
:
fmt
.
Sprintf
(
"kubelet has sufficient disk space available"
),
LastHeartbeatTime
:
metav1
.
Time
{},
LastTransitionTime
:
metav1
.
Time
{},
},
{
Type
:
v1
.
NodeMemoryPressure
,
Status
:
v1
.
ConditionFalse
,
Reason
:
"KubeletHasSufficientMemory"
,
...
...
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