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
d84a8c56
Commit
d84a8c56
authored
Mar 30, 2019
by
madianjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve for-loop in nodesWherePreemptionMightHelp function
parent
a9db1377
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
27 deletions
+32
-27
generic_scheduler.go
pkg/scheduler/core/generic_scheduler.go
+32
-27
No files found.
pkg/scheduler/core/generic_scheduler.go
View file @
d84a8c56
...
...
@@ -62,6 +62,27 @@ const (
minFeasibleNodesPercentageToFind
=
5
)
var
unresolvablePredicateFailureErrors
=
map
[
predicates
.
PredicateFailureReason
]
struct
{}{
predicates
.
ErrNodeSelectorNotMatch
:
{},
predicates
.
ErrPodAffinityRulesNotMatch
:
{},
predicates
.
ErrPodNotMatchHostName
:
{},
predicates
.
ErrTaintsTolerationsNotMatch
:
{},
predicates
.
ErrNodeLabelPresenceViolated
:
{},
// Node conditions won't change when scheduler simulates removal of preemption victims.
// So, it is pointless to try nodes that have not been able to host the pod due to node
// conditions. These include ErrNodeNotReady, ErrNodeUnderPIDPressure, ErrNodeUnderMemoryPressure, ....
predicates
.
ErrNodeNotReady
:
{},
predicates
.
ErrNodeNetworkUnavailable
:
{},
predicates
.
ErrNodeUnderDiskPressure
:
{},
predicates
.
ErrNodeUnderPIDPressure
:
{},
predicates
.
ErrNodeUnderMemoryPressure
:
{},
predicates
.
ErrNodeUnschedulable
:
{},
predicates
.
ErrNodeUnknownCondition
:
{},
predicates
.
ErrVolumeZoneConflict
:
{},
predicates
.
ErrVolumeNodeConflict
:
{},
predicates
.
ErrVolumeBindConflict
:
{},
}
// FailedPredicateMap declares a map[string][]algorithm.PredicateFailureReason type.
type
FailedPredicateMap
map
[
string
][]
predicates
.
PredicateFailureReason
...
...
@@ -1111,44 +1132,28 @@ func selectVictimsOnNode(
return
victims
,
numViolatingVictim
,
true
}
// unresolvablePredicateExists checks whether failedPredicates has unresolvable predicate.
func
unresolvablePredicateExists
(
failedPredicates
[]
predicates
.
PredicateFailureReason
)
bool
{
for
_
,
failedPredicate
:=
range
failedPredicates
{
if
_
,
ok
:=
unresolvablePredicateFailureErrors
[
failedPredicate
];
ok
{
return
true
}
}
return
false
}
// nodesWherePreemptionMightHelp returns a list of nodes with failed predicates
// that may be satisfied by removing pods from the node.
func
nodesWherePreemptionMightHelp
(
nodes
[]
*
v1
.
Node
,
failedPredicatesMap
FailedPredicateMap
)
[]
*
v1
.
Node
{
potentialNodes
:=
[]
*
v1
.
Node
{}
for
_
,
node
:=
range
nodes
{
unresolvableReasonExist
:=
false
failedPredicates
,
_
:=
failedPredicatesMap
[
node
.
Name
]
// If we assume that scheduler looks at all nodes and populates the failedPredicateMap
// (which is the case today), the !found case should never happen, but we'd prefer
// to rely less on such assumptions in the code when checking does not impose
// significant overhead.
// Also, we currently assume all failures returned by extender as resolvable.
for
_
,
failedPredicate
:=
range
failedPredicates
{
switch
failedPredicate
{
case
predicates
.
ErrNodeSelectorNotMatch
,
predicates
.
ErrPodAffinityRulesNotMatch
,
predicates
.
ErrPodNotMatchHostName
,
predicates
.
ErrTaintsTolerationsNotMatch
,
predicates
.
ErrNodeLabelPresenceViolated
,
// Node conditions won't change when scheduler simulates removal of preemption victims.
// So, it is pointless to try nodes that have not been able to host the pod due to node
// conditions. These include ErrNodeNotReady, ErrNodeUnderPIDPressure, ErrNodeUnderMemoryPressure, ....
predicates
.
ErrNodeNotReady
,
predicates
.
ErrNodeNetworkUnavailable
,
predicates
.
ErrNodeUnderDiskPressure
,
predicates
.
ErrNodeUnderPIDPressure
,
predicates
.
ErrNodeUnderMemoryPressure
,
predicates
.
ErrNodeUnschedulable
,
predicates
.
ErrNodeUnknownCondition
,
predicates
.
ErrVolumeZoneConflict
,
predicates
.
ErrVolumeNodeConflict
,
predicates
.
ErrVolumeBindConflict
:
unresolvableReasonExist
=
true
break
}
}
if
!
unresolvableReasonExist
{
if
!
unresolvablePredicateExists
(
failedPredicates
)
{
klog
.
V
(
3
)
.
Infof
(
"Node %v is a potential node for preemption."
,
node
.
Name
)
potentialNodes
=
append
(
potentialNodes
,
node
)
}
...
...
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