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
78f6484e
Commit
78f6484e
authored
Sep 23, 2018
by
Da K. Ma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keep backward compatibility for 'node.Spec.Unschedulable'.
Signed-off-by:
Da K. Ma
<
klaus1982.cn@gmail.com
>
parent
488f0fcd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
1 deletion
+73
-1
predicates.go
pkg/scheduler/algorithm/predicates/predicates.go
+8
-1
predicates_test.go
pkg/scheduler/algorithm/predicates/predicates_test.go
+62
-0
defaults.go
pkg/scheduler/algorithmprovider/defaults/defaults.go
+3
-0
No files found.
pkg/scheduler/algorithm/predicates/predicates.go
View file @
78f6484e
...
...
@@ -1470,7 +1470,14 @@ func CheckNodeUnschedulablePredicate(pod *v1.Pod, meta algorithm.PredicateMetada
return
false
,
[]
algorithm
.
PredicateFailureReason
{
ErrNodeUnknownCondition
},
nil
}
if
nodeInfo
.
Node
()
.
Spec
.
Unschedulable
{
// If pod tolerate unschedulable taint, it's also tolerate `node.Spec.Unschedulable`.
podToleratesUnschedulable
:=
v1helper
.
TolerationsTolerateTaint
(
pod
.
Spec
.
Tolerations
,
&
v1
.
Taint
{
Key
:
algorithm
.
TaintNodeUnschedulable
,
Effect
:
v1
.
TaintEffectNoSchedule
,
})
// TODO (k82cn): deprecates `node.Spec.Unschedulable` in 1.13.
if
nodeInfo
.
Node
()
.
Spec
.
Unschedulable
&&
!
podToleratesUnschedulable
{
return
false
,
[]
algorithm
.
PredicateFailureReason
{
ErrNodeUnschedulable
},
nil
}
...
...
pkg/scheduler/algorithm/predicates/predicates_test.go
View file @
78f6484e
...
...
@@ -4982,3 +4982,65 @@ func TestGetMaxVols(t *testing.T) {
os
.
Setenv
(
KubeMaxPDVols
,
previousValue
)
}
}
func
TestCheckNodeUnschedulablePredicate
(
t
*
testing
.
T
)
{
testCases
:=
[]
struct
{
name
string
pod
*
v1
.
Pod
node
*
v1
.
Node
fit
bool
}{
{
name
:
"Does not schedule pod to unschedulable node (node.Spec.Unschedulable==true)"
,
pod
:
&
v1
.
Pod
{},
node
:
&
v1
.
Node
{
Spec
:
v1
.
NodeSpec
{
Unschedulable
:
true
,
},
},
fit
:
false
,
},
{
name
:
"Schedule pod to normal node"
,
pod
:
&
v1
.
Pod
{},
node
:
&
v1
.
Node
{
Spec
:
v1
.
NodeSpec
{
Unschedulable
:
false
,
},
},
fit
:
true
,
},
{
name
:
"Schedule pod with toleration to unschedulable node (node.Spec.Unschedulable==true)"
,
pod
:
&
v1
.
Pod
{
Spec
:
v1
.
PodSpec
{
Tolerations
:
[]
v1
.
Toleration
{
{
Key
:
algorithm
.
TaintNodeUnschedulable
,
Effect
:
v1
.
TaintEffectNoSchedule
,
},
},
},
},
node
:
&
v1
.
Node
{
Spec
:
v1
.
NodeSpec
{
Unschedulable
:
true
,
},
},
fit
:
true
,
},
}
for
_
,
test
:=
range
testCases
{
nodeInfo
:=
schedulercache
.
NewNodeInfo
()
nodeInfo
.
SetNode
(
test
.
node
)
fit
,
_
,
err
:=
CheckNodeUnschedulablePredicate
(
test
.
pod
,
nil
,
nodeInfo
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to check node unschedulable: %v"
,
err
)
}
if
fit
!=
test
.
fit
{
t
.
Errorf
(
"Unexpected fit: expected %v, got %v"
,
test
.
fit
,
fit
)
}
}
}
pkg/scheduler/algorithmprovider/defaults/defaults.go
View file @
78f6484e
...
...
@@ -199,10 +199,13 @@ func ApplyFeatureGates() {
// Fit is determined based on whether a pod can tolerate all of the node's taints
factory
.
RegisterMandatoryFitPredicate
(
predicates
.
PodToleratesNodeTaintsPred
,
predicates
.
PodToleratesNodeTaints
)
// Fit is determined based on whether a pod can tolerate unschedulable of node
factory
.
RegisterMandatoryFitPredicate
(
predicates
.
CheckNodeUnschedulablePred
,
predicates
.
CheckNodeUnschedulablePredicate
)
// Insert Key "PodToleratesNodeTaints" and "CheckNodeUnschedulable" To All Algorithm Provider
// The key will insert to all providers which in algorithmProviderMap[]
// if you just want insert to specific provider, call func InsertPredicateKeyToAlgoProvider()
factory
.
InsertPredicateKeyToAlgorithmProviderMap
(
predicates
.
PodToleratesNodeTaintsPred
)
factory
.
InsertPredicateKeyToAlgorithmProviderMap
(
predicates
.
CheckNodeUnschedulablePred
)
glog
.
Warningf
(
"TaintNodesByCondition is enabled, PodToleratesNodeTaints predicate is mandatory"
)
}
...
...
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