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
1b5666fc
Commit
1b5666fc
authored
Dec 07, 2016
by
Kubernetes Submit Queue
Committed by
GitHub
Dec 07, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #35275 from wojtek-t/cache_conditions
Automatic merge from submit-queue Cache additional information in schedulercache.NodeInfo to speedup scheduler Ref #35117
parents
98a2808b
7387bc05
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
35 deletions
+63
-35
predicates.go
plugin/pkg/scheduler/algorithm/predicates/predicates.go
+7
-29
node_info.go
plugin/pkg/scheduler/schedulercache/node_info.go
+56
-6
No files found.
plugin/pkg/scheduler/algorithm/predicates/predicates.go
View file @
1b5666fc
...
...
@@ -1119,12 +1119,7 @@ func (c *PodAffinityChecker) satisfiesPodsAffinityAntiAffinity(pod *v1.Pod, node
}
func
PodToleratesNodeTaints
(
pod
*
v1
.
Pod
,
meta
interface
{},
nodeInfo
*
schedulercache
.
NodeInfo
)
(
bool
,
[]
algorithm
.
PredicateFailureReason
,
error
)
{
node
:=
nodeInfo
.
Node
()
if
node
==
nil
{
return
false
,
nil
,
fmt
.
Errorf
(
"node not found"
)
}
taints
,
err
:=
v1
.
GetTaintsFromNodeAnnotations
(
node
.
Annotations
)
taints
,
err
:=
nodeInfo
.
Taints
()
if
err
!=
nil
{
return
false
,
nil
,
err
}
...
...
@@ -1174,11 +1169,6 @@ func isPodBestEffort(pod *v1.Pod) bool {
// CheckNodeMemoryPressurePredicate checks if a pod can be scheduled on a node
// reporting memory pressure condition.
func
CheckNodeMemoryPressurePredicate
(
pod
*
v1
.
Pod
,
meta
interface
{},
nodeInfo
*
schedulercache
.
NodeInfo
)
(
bool
,
[]
algorithm
.
PredicateFailureReason
,
error
)
{
node
:=
nodeInfo
.
Node
()
if
node
==
nil
{
return
false
,
nil
,
fmt
.
Errorf
(
"node not found"
)
}
var
podBestEffort
bool
if
predicateMeta
,
ok
:=
meta
.
(
*
predicateMetadata
);
ok
{
podBestEffort
=
predicateMeta
.
podBestEffort
...
...
@@ -1186,36 +1176,24 @@ func CheckNodeMemoryPressurePredicate(pod *v1.Pod, meta interface{}, nodeInfo *s
// We couldn't parse metadata - fallback to computing it.
podBestEffort
=
isPodBestEffort
(
pod
)
}
// pod is not BestEffort pod
if
!
podBestEffort
{
return
true
,
nil
,
nil
}
// is node under pressure?
for
_
,
cond
:=
range
node
.
Status
.
Conditions
{
if
cond
.
Type
==
v1
.
NodeMemoryPressure
&&
cond
.
Status
==
v1
.
ConditionTrue
{
return
false
,
[]
algorithm
.
PredicateFailureReason
{
ErrNodeUnderMemoryPressure
},
nil
}
// is node under presure?
if
nodeInfo
.
MemoryPressureCondition
()
==
v1
.
ConditionTrue
{
return
false
,
[]
algorithm
.
PredicateFailureReason
{
ErrNodeUnderMemoryPressure
},
nil
}
return
true
,
nil
,
nil
}
// CheckNodeDiskPressurePredicate checks if a pod can be scheduled on a node
// reporting disk pressure condition.
func
CheckNodeDiskPressurePredicate
(
pod
*
v1
.
Pod
,
meta
interface
{},
nodeInfo
*
schedulercache
.
NodeInfo
)
(
bool
,
[]
algorithm
.
PredicateFailureReason
,
error
)
{
node
:=
nodeInfo
.
Node
()
if
node
==
nil
{
return
false
,
nil
,
fmt
.
Errorf
(
"node not found"
)
// is node under presure?
if
node
Info
.
DiskPressureCondition
()
==
v1
.
ConditionTrue
{
return
false
,
[]
algorithm
.
PredicateFailureReason
{
ErrNodeUnderDiskPressure
},
nil
}
// is node under pressure?
for
_
,
cond
:=
range
node
.
Status
.
Conditions
{
if
cond
.
Type
==
v1
.
NodeDiskPressure
&&
cond
.
Status
==
v1
.
ConditionTrue
{
return
false
,
[]
algorithm
.
PredicateFailureReason
{
ErrNodeUnderDiskPressure
},
nil
}
}
return
true
,
nil
,
nil
}
plugin/pkg/scheduler/schedulercache/node_info.go
View file @
1b5666fc
...
...
@@ -49,6 +49,14 @@ type NodeInfo struct {
// explicitly as int, to avoid conversions and improve performance.
allowedPodNumber
int
// Cached tains of the node for faster lookup.
taints
[]
v1
.
Taint
taintsErr
error
// Cached conditions of node for faster lookup.
memoryPressureCondition
v1
.
ConditionStatus
diskPressureCondition
v1
.
ConditionStatus
// Whenever NodeInfo changes, generation is bumped.
// This is used to avoid cloning it if the object didn't change.
generation
int64
...
...
@@ -122,6 +130,27 @@ func (n *NodeInfo) AllowedPodNumber() int {
return
n
.
allowedPodNumber
}
func
(
n
*
NodeInfo
)
Taints
()
([]
v1
.
Taint
,
error
)
{
if
n
==
nil
{
return
nil
,
nil
}
return
n
.
taints
,
n
.
taintsErr
}
func
(
n
*
NodeInfo
)
MemoryPressureCondition
()
v1
.
ConditionStatus
{
if
n
==
nil
{
return
v1
.
ConditionUnknown
}
return
n
.
memoryPressureCondition
}
func
(
n
*
NodeInfo
)
DiskPressureCondition
()
v1
.
ConditionStatus
{
if
n
==
nil
{
return
v1
.
ConditionUnknown
}
return
n
.
diskPressureCondition
}
// RequestedResource returns aggregated resource request of pods on this node.
func
(
n
*
NodeInfo
)
RequestedResource
()
Resource
{
if
n
==
nil
{
...
...
@@ -148,12 +177,15 @@ func (n *NodeInfo) AllocatableResource() Resource {
func
(
n
*
NodeInfo
)
Clone
()
*
NodeInfo
{
clone
:=
&
NodeInfo
{
node
:
n
.
node
,
requestedResource
:
&
(
*
n
.
requestedResource
),
nonzeroRequest
:
&
(
*
n
.
nonzeroRequest
),
allocatableResource
:
&
(
*
n
.
allocatableResource
),
allowedPodNumber
:
n
.
allowedPodNumber
,
generation
:
n
.
generation
,
node
:
n
.
node
,
requestedResource
:
&
(
*
n
.
requestedResource
),
nonzeroRequest
:
&
(
*
n
.
nonzeroRequest
),
allocatableResource
:
&
(
*
n
.
allocatableResource
),
allowedPodNumber
:
n
.
allowedPodNumber
,
taintsErr
:
n
.
taintsErr
,
memoryPressureCondition
:
n
.
memoryPressureCondition
,
diskPressureCondition
:
n
.
diskPressureCondition
,
generation
:
n
.
generation
,
}
if
len
(
n
.
pods
)
>
0
{
clone
.
pods
=
append
([]
*
v1
.
Pod
(
nil
),
n
.
pods
...
)
...
...
@@ -161,6 +193,9 @@ func (n *NodeInfo) Clone() *NodeInfo {
if
len
(
n
.
podsWithAffinity
)
>
0
{
clone
.
podsWithAffinity
=
append
([]
*
v1
.
Pod
(
nil
),
n
.
podsWithAffinity
...
)
}
if
len
(
n
.
taints
)
>
0
{
clone
.
taints
=
append
([]
v1
.
Taint
(
nil
),
n
.
taints
...
)
}
return
clone
}
...
...
@@ -306,6 +341,18 @@ func (n *NodeInfo) SetNode(node *v1.Node) error {
}
}
}
n
.
taints
,
n
.
taintsErr
=
v1
.
GetTaintsFromNodeAnnotations
(
node
.
Annotations
)
for
i
:=
range
node
.
Status
.
Conditions
{
cond
:=
&
node
.
Status
.
Conditions
[
i
]
switch
cond
.
Type
{
case
v1
.
NodeMemoryPressure
:
n
.
memoryPressureCondition
=
cond
.
Status
case
v1
.
NodeDiskPressure
:
n
.
diskPressureCondition
=
cond
.
Status
default
:
// We ignore other conditions.
}
}
n
.
generation
++
return
nil
}
...
...
@@ -319,6 +366,9 @@ func (n *NodeInfo) RemoveNode(node *v1.Node) error {
n
.
node
=
nil
n
.
allocatableResource
=
&
Resource
{}
n
.
allowedPodNumber
=
0
n
.
taints
,
n
.
taintsErr
=
nil
,
nil
n
.
memoryPressureCondition
=
v1
.
ConditionUnknown
n
.
diskPressureCondition
=
v1
.
ConditionUnknown
n
.
generation
++
return
nil
}
...
...
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