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
7387bc05
Commit
7387bc05
authored
Oct 21, 2016
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cache node taints in scheduler NodeInfo
parent
be2bb399
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
+18
-6
predicates.go
plugin/pkg/scheduler/algorithm/predicates/predicates.go
+1
-6
node_info.go
plugin/pkg/scheduler/schedulercache/node_info.go
+17
-0
No files found.
plugin/pkg/scheduler/algorithm/predicates/predicates.go
View file @
7387bc05
...
@@ -1119,12 +1119,7 @@ func (c *PodAffinityChecker) satisfiesPodsAffinityAntiAffinity(pod *v1.Pod, node
...
@@ -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
)
{
func
PodToleratesNodeTaints
(
pod
*
v1
.
Pod
,
meta
interface
{},
nodeInfo
*
schedulercache
.
NodeInfo
)
(
bool
,
[]
algorithm
.
PredicateFailureReason
,
error
)
{
node
:=
nodeInfo
.
Node
()
taints
,
err
:=
nodeInfo
.
Taints
()
if
node
==
nil
{
return
false
,
nil
,
fmt
.
Errorf
(
"node not found"
)
}
taints
,
err
:=
v1
.
GetTaintsFromNodeAnnotations
(
node
.
Annotations
)
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
nil
,
err
return
false
,
nil
,
err
}
}
...
...
plugin/pkg/scheduler/schedulercache/node_info.go
View file @
7387bc05
...
@@ -49,6 +49,10 @@ type NodeInfo struct {
...
@@ -49,6 +49,10 @@ type NodeInfo struct {
// explicitly as int, to avoid conversions and improve performance.
// explicitly as int, to avoid conversions and improve performance.
allowedPodNumber
int
allowedPodNumber
int
// Cached tains of the node for faster lookup.
taints
[]
v1
.
Taint
taintsErr
error
// Cached conditions of node for faster lookup.
// Cached conditions of node for faster lookup.
memoryPressureCondition
v1
.
ConditionStatus
memoryPressureCondition
v1
.
ConditionStatus
diskPressureCondition
v1
.
ConditionStatus
diskPressureCondition
v1
.
ConditionStatus
...
@@ -126,6 +130,13 @@ func (n *NodeInfo) AllowedPodNumber() int {
...
@@ -126,6 +130,13 @@ func (n *NodeInfo) AllowedPodNumber() int {
return
n
.
allowedPodNumber
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
{
func
(
n
*
NodeInfo
)
MemoryPressureCondition
()
v1
.
ConditionStatus
{
if
n
==
nil
{
if
n
==
nil
{
return
v1
.
ConditionUnknown
return
v1
.
ConditionUnknown
...
@@ -171,6 +182,7 @@ func (n *NodeInfo) Clone() *NodeInfo {
...
@@ -171,6 +182,7 @@ func (n *NodeInfo) Clone() *NodeInfo {
nonzeroRequest
:
&
(
*
n
.
nonzeroRequest
),
nonzeroRequest
:
&
(
*
n
.
nonzeroRequest
),
allocatableResource
:
&
(
*
n
.
allocatableResource
),
allocatableResource
:
&
(
*
n
.
allocatableResource
),
allowedPodNumber
:
n
.
allowedPodNumber
,
allowedPodNumber
:
n
.
allowedPodNumber
,
taintsErr
:
n
.
taintsErr
,
memoryPressureCondition
:
n
.
memoryPressureCondition
,
memoryPressureCondition
:
n
.
memoryPressureCondition
,
diskPressureCondition
:
n
.
diskPressureCondition
,
diskPressureCondition
:
n
.
diskPressureCondition
,
generation
:
n
.
generation
,
generation
:
n
.
generation
,
...
@@ -181,6 +193,9 @@ func (n *NodeInfo) Clone() *NodeInfo {
...
@@ -181,6 +193,9 @@ func (n *NodeInfo) Clone() *NodeInfo {
if
len
(
n
.
podsWithAffinity
)
>
0
{
if
len
(
n
.
podsWithAffinity
)
>
0
{
clone
.
podsWithAffinity
=
append
([]
*
v1
.
Pod
(
nil
),
n
.
podsWithAffinity
...
)
clone
.
podsWithAffinity
=
append
([]
*
v1
.
Pod
(
nil
),
n
.
podsWithAffinity
...
)
}
}
if
len
(
n
.
taints
)
>
0
{
clone
.
taints
=
append
([]
v1
.
Taint
(
nil
),
n
.
taints
...
)
}
return
clone
return
clone
}
}
...
@@ -326,6 +341,7 @@ func (n *NodeInfo) SetNode(node *v1.Node) error {
...
@@ -326,6 +341,7 @@ func (n *NodeInfo) SetNode(node *v1.Node) error {
}
}
}
}
}
}
n
.
taints
,
n
.
taintsErr
=
v1
.
GetTaintsFromNodeAnnotations
(
node
.
Annotations
)
for
i
:=
range
node
.
Status
.
Conditions
{
for
i
:=
range
node
.
Status
.
Conditions
{
cond
:=
&
node
.
Status
.
Conditions
[
i
]
cond
:=
&
node
.
Status
.
Conditions
[
i
]
switch
cond
.
Type
{
switch
cond
.
Type
{
...
@@ -350,6 +366,7 @@ func (n *NodeInfo) RemoveNode(node *v1.Node) error {
...
@@ -350,6 +366,7 @@ func (n *NodeInfo) RemoveNode(node *v1.Node) error {
n
.
node
=
nil
n
.
node
=
nil
n
.
allocatableResource
=
&
Resource
{}
n
.
allocatableResource
=
&
Resource
{}
n
.
allowedPodNumber
=
0
n
.
allowedPodNumber
=
0
n
.
taints
,
n
.
taintsErr
=
nil
,
nil
n
.
memoryPressureCondition
=
v1
.
ConditionUnknown
n
.
memoryPressureCondition
=
v1
.
ConditionUnknown
n
.
diskPressureCondition
=
v1
.
ConditionUnknown
n
.
diskPressureCondition
=
v1
.
ConditionUnknown
n
.
generation
++
n
.
generation
++
...
...
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