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
be2bb399
Commit
be2bb399
authored
Oct 21, 2016
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cache node conditions in scheduler NodeInfo
parent
124fb610
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
29 deletions
+45
-29
predicates.go
plugin/pkg/scheduler/algorithm/predicates/predicates.go
+6
-23
node_info.go
plugin/pkg/scheduler/schedulercache/node_info.go
+39
-6
No files found.
plugin/pkg/scheduler/algorithm/predicates/predicates.go
View file @
be2bb399
...
...
@@ -1174,11 +1174,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 +1181,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 @
be2bb399
...
...
@@ -49,6 +49,10 @@ type NodeInfo struct {
// explicitly as int, to avoid conversions and improve performance.
allowedPodNumber
int
// 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 +126,20 @@ func (n *NodeInfo) AllowedPodNumber() int {
return
n
.
allowedPodNumber
}
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 +166,14 @@ 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
,
memoryPressureCondition
:
n
.
memoryPressureCondition
,
diskPressureCondition
:
n
.
diskPressureCondition
,
generation
:
n
.
generation
,
}
if
len
(
n
.
pods
)
>
0
{
clone
.
pods
=
append
([]
*
v1
.
Pod
(
nil
),
n
.
pods
...
)
...
...
@@ -306,6 +326,17 @@ func (n *NodeInfo) SetNode(node *v1.Node) error {
}
}
}
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 +350,8 @@ func (n *NodeInfo) RemoveNode(node *v1.Node) error {
n
.
node
=
nil
n
.
allocatableResource
=
&
Resource
{}
n
.
allowedPodNumber
=
0
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