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
4eb72d7b
Commit
4eb72d7b
authored
May 14, 2018
by
ceshihao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify code and add unit test for NotReady taint
parent
842ae0bc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
18 deletions
+48
-18
node_lifecycle_controller.go
pkg/controller/nodelifecycle/node_lifecycle_controller.go
+20
-18
node_lifecycle_controller_test.go
...ontroller/nodelifecycle/node_lifecycle_controller_test.go
+28
-0
No files found.
pkg/controller/nodelifecycle/node_lifecycle_controller.go
View file @
4eb72d7b
...
...
@@ -81,32 +81,34 @@ var (
}
nodeConditionToTaintKeyStatusMap
=
map
[
v1
.
NodeConditionType
]
struct
{
TaintKey
string
Status
v1
.
ConditionStatus
taintKey
string
// noScheduleStatus is the condition under which the node should be tainted as not schedulable for this
// NodeConditionType
noScheduleStatus
v1
.
ConditionStatus
}{
v1
.
NodeReady
:
{
TaintKey
:
algorithm
.
TaintNodeNotReady
,
Status
:
v1
.
ConditionFalse
,
taintKey
:
algorithm
.
TaintNodeNotReady
,
noScheduleStatus
:
v1
.
ConditionFalse
,
},
v1
.
NodeMemoryPressure
:
{
TaintKey
:
algorithm
.
TaintNodeMemoryPressure
,
Status
:
v1
.
ConditionTrue
,
taintKey
:
algorithm
.
TaintNodeMemoryPressure
,
noScheduleStatus
:
v1
.
ConditionTrue
,
},
v1
.
NodeOutOfDisk
:
{
TaintKey
:
algorithm
.
TaintNodeOutOfDisk
,
Status
:
v1
.
ConditionTrue
,
taintKey
:
algorithm
.
TaintNodeOutOfDisk
,
noScheduleStatus
:
v1
.
ConditionTrue
,
},
v1
.
NodeDiskPressure
:
{
TaintKey
:
algorithm
.
TaintNodeDiskPressure
,
Status
:
v1
.
ConditionTrue
,
taintKey
:
algorithm
.
TaintNodeDiskPressure
,
noScheduleStatus
:
v1
.
ConditionTrue
,
},
v1
.
NodeNetworkUnavailable
:
{
TaintKey
:
algorithm
.
TaintNodeNetworkUnavailable
,
Status
:
v1
.
ConditionTrue
,
taintKey
:
algorithm
.
TaintNodeNetworkUnavailable
,
noScheduleStatus
:
v1
.
ConditionTrue
,
},
v1
.
NodePIDPressure
:
{
TaintKey
:
algorithm
.
TaintNodePIDPressure
,
Status
:
v1
.
ConditionTrue
,
taintKey
:
algorithm
.
TaintNodePIDPressure
,
noScheduleStatus
:
v1
.
ConditionTrue
,
},
}
...
...
@@ -453,12 +455,12 @@ func (nc *Controller) doFixDeprecatedTaintKeyPass(node *v1.Node) error {
func
(
nc
*
Controller
)
doNoScheduleTaintingPass
(
node
*
v1
.
Node
)
error
{
// Map node's condition to Taints.
taints
:=
[]
v1
.
Taint
{}
var
taints
[]
v1
.
Taint
for
_
,
condition
:=
range
node
.
Status
.
Conditions
{
if
taint
KeyStatus
,
found
:=
nodeConditionToTaintKeyStatusMap
[
condition
.
Type
];
found
{
if
condition
.
Status
==
taint
KeyStatus
.
Status
{
if
taint
,
found
:=
nodeConditionToTaintKeyStatusMap
[
condition
.
Type
];
found
{
if
condition
.
Status
==
taint
.
noSchedule
Status
{
taints
=
append
(
taints
,
v1
.
Taint
{
Key
:
taint
KeyStatus
.
T
aintKey
,
Key
:
taint
.
t
aintKey
,
Effect
:
v1
.
TaintEffectNoSchedule
,
})
}
...
...
pkg/controller/nodelifecycle/node_lifecycle_controller_test.go
View file @
4eb72d7b
...
...
@@ -2163,6 +2163,10 @@ func TestTaintsNodeByCondition(t *testing.T) {
Key
:
algorithm
.
TaintNodeNetworkUnavailable
,
Effect
:
v1
.
TaintEffectNoSchedule
,
}
notReadyTaint
:=
&
v1
.
Taint
{
Key
:
algorithm
.
TaintNodeNotReady
,
Effect
:
v1
.
TaintEffectNoSchedule
,
}
tests
:=
[]
struct
{
Name
string
...
...
@@ -2271,6 +2275,30 @@ func TestTaintsNodeByCondition(t *testing.T) {
},
ExpectedTaints
:
[]
*
v1
.
Taint
{
networkUnavailableTaint
},
},
{
Name
:
"Ready is false"
,
Node
:
&
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"node0"
,
CreationTimestamp
:
metav1
.
Date
(
2012
,
1
,
1
,
0
,
0
,
0
,
0
,
time
.
UTC
),
Labels
:
map
[
string
]
string
{
kubeletapis
.
LabelZoneRegion
:
"region1"
,
kubeletapis
.
LabelZoneFailureDomain
:
"zone1"
,
},
},
Status
:
v1
.
NodeStatus
{
Conditions
:
[]
v1
.
NodeCondition
{
{
Type
:
v1
.
NodeReady
,
Status
:
v1
.
ConditionFalse
,
LastHeartbeatTime
:
metav1
.
Date
(
2015
,
1
,
1
,
12
,
0
,
0
,
0
,
time
.
UTC
),
LastTransitionTime
:
metav1
.
Date
(
2015
,
1
,
1
,
12
,
0
,
0
,
0
,
time
.
UTC
),
},
},
},
},
ExpectedTaints
:
[]
*
v1
.
Taint
{
notReadyTaint
},
},
}
for
_
,
test
:=
range
tests
{
...
...
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