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
6c77c01f
Commit
6c77c01f
authored
Jul 07, 2016
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid copying nodes in priority functions
parent
7219802a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
8 deletions
+15
-8
node_affinity.go
plugin/pkg/scheduler/algorithm/priorities/node_affinity.go
+2
-1
priorities.go
plugin/pkg/scheduler/algorithm/priorities/priorities.go
+11
-6
taint_toleration.go
...in/pkg/scheduler/algorithm/priorities/taint_toleration.go
+2
-1
No files found.
plugin/pkg/scheduler/algorithm/priorities/node_affinity.go
View file @
6c77c01f
...
@@ -83,7 +83,8 @@ func (s *NodeAffinity) CalculateNodeAffinityPriority(pod *api.Pod, nodeNameToInf
...
@@ -83,7 +83,8 @@ func (s *NodeAffinity) CalculateNodeAffinityPriority(pod *api.Pod, nodeNameToInf
}
}
result
:=
[]
schedulerapi
.
HostPriority
{}
result
:=
[]
schedulerapi
.
HostPriority
{}
for
_
,
node
:=
range
nodes
.
Items
{
for
i
:=
range
nodes
.
Items
{
node
:=
&
nodes
.
Items
[
i
]
fScore
:=
float64
(
0
)
fScore
:=
float64
(
0
)
if
maxCount
>
0
{
if
maxCount
>
0
{
fScore
=
10
*
(
float64
(
counts
[
node
.
Name
])
/
float64
(
maxCount
))
fScore
=
10
*
(
float64
(
counts
[
node
.
Name
])
/
float64
(
maxCount
))
...
...
plugin/pkg/scheduler/algorithm/priorities/priorities.go
View file @
6c77c01f
...
@@ -44,7 +44,8 @@ func calculateScore(requested int64, capacity int64, node string) int {
...
@@ -44,7 +44,8 @@ func calculateScore(requested int64, capacity int64, node string) int {
// Calculate the resource occupancy on a node. 'node' has information about the resources on the node.
// Calculate the resource occupancy on a node. 'node' has information about the resources on the node.
// 'pods' is a list of pods currently scheduled on the node.
// 'pods' is a list of pods currently scheduled on the node.
func
calculateResourceOccupancy
(
pod
*
api
.
Pod
,
node
api
.
Node
,
nodeInfo
*
schedulercache
.
NodeInfo
)
schedulerapi
.
HostPriority
{
// TODO: Use Node() from nodeInfo instead of passing it.
func
calculateResourceOccupancy
(
pod
*
api
.
Pod
,
node
*
api
.
Node
,
nodeInfo
*
schedulercache
.
NodeInfo
)
schedulerapi
.
HostPriority
{
totalMilliCPU
:=
nodeInfo
.
NonZeroRequest
()
.
MilliCPU
totalMilliCPU
:=
nodeInfo
.
NonZeroRequest
()
.
MilliCPU
totalMemory
:=
nodeInfo
.
NonZeroRequest
()
.
Memory
totalMemory
:=
nodeInfo
.
NonZeroRequest
()
.
Memory
capacityMilliCPU
:=
node
.
Status
.
Allocatable
.
Cpu
()
.
MilliValue
()
capacityMilliCPU
:=
node
.
Status
.
Allocatable
.
Cpu
()
.
MilliValue
()
...
@@ -85,7 +86,8 @@ func LeastRequestedPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulerca
...
@@ -85,7 +86,8 @@ func LeastRequestedPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulerca
}
}
list
:=
schedulerapi
.
HostPriorityList
{}
list
:=
schedulerapi
.
HostPriorityList
{}
for
_
,
node
:=
range
nodes
.
Items
{
for
i
:=
range
nodes
.
Items
{
node
:=
&
nodes
.
Items
[
i
]
list
=
append
(
list
,
calculateResourceOccupancy
(
pod
,
node
,
nodeNameToInfo
[
node
.
Name
]))
list
=
append
(
list
,
calculateResourceOccupancy
(
pod
,
node
,
nodeNameToInfo
[
node
.
Name
]))
}
}
return
list
,
nil
return
list
,
nil
...
@@ -155,7 +157,8 @@ func ImageLocalityPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulercac
...
@@ -155,7 +157,8 @@ func ImageLocalityPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulercac
}
}
for
_
,
container
:=
range
pod
.
Spec
.
Containers
{
for
_
,
container
:=
range
pod
.
Spec
.
Containers
{
for
_
,
node
:=
range
nodes
.
Items
{
for
i
:=
range
nodes
.
Items
{
node
:=
&
nodes
.
Items
[
i
]
// Check if this container's image is present and get its size.
// Check if this container's image is present and get its size.
imageSize
:=
checkContainerImageOnNode
(
node
,
container
)
imageSize
:=
checkContainerImageOnNode
(
node
,
container
)
// Add this size to the total result of this node.
// Add this size to the total result of this node.
...
@@ -174,7 +177,7 @@ func ImageLocalityPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulercac
...
@@ -174,7 +177,7 @@ func ImageLocalityPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulercac
}
}
// checkContainerImageOnNode checks if a container image is present on a node and returns its size.
// checkContainerImageOnNode checks if a container image is present on a node and returns its size.
func
checkContainerImageOnNode
(
node
api
.
Node
,
container
api
.
Container
)
int64
{
func
checkContainerImageOnNode
(
node
*
api
.
Node
,
container
api
.
Container
)
int64
{
for
_
,
image
:=
range
node
.
Status
.
Images
{
for
_
,
image
:=
range
node
.
Status
.
Images
{
for
_
,
name
:=
range
image
.
Names
{
for
_
,
name
:=
range
image
.
Names
{
if
container
.
Image
==
name
{
if
container
.
Image
==
name
{
...
@@ -219,13 +222,15 @@ func BalancedResourceAllocation(pod *api.Pod, nodeNameToInfo map[string]*schedul
...
@@ -219,13 +222,15 @@ func BalancedResourceAllocation(pod *api.Pod, nodeNameToInfo map[string]*schedul
}
}
list
:=
schedulerapi
.
HostPriorityList
{}
list
:=
schedulerapi
.
HostPriorityList
{}
for
_
,
node
:=
range
nodes
.
Items
{
for
i
:=
range
nodes
.
Items
{
node
:=
&
nodes
.
Items
[
i
]
list
=
append
(
list
,
calculateBalancedResourceAllocation
(
pod
,
node
,
nodeNameToInfo
[
node
.
Name
]))
list
=
append
(
list
,
calculateBalancedResourceAllocation
(
pod
,
node
,
nodeNameToInfo
[
node
.
Name
]))
}
}
return
list
,
nil
return
list
,
nil
}
}
func
calculateBalancedResourceAllocation
(
pod
*
api
.
Pod
,
node
api
.
Node
,
nodeInfo
*
schedulercache
.
NodeInfo
)
schedulerapi
.
HostPriority
{
// TODO: Use Node() from nodeInfo instead of passing it.
func
calculateBalancedResourceAllocation
(
pod
*
api
.
Pod
,
node
*
api
.
Node
,
nodeInfo
*
schedulercache
.
NodeInfo
)
schedulerapi
.
HostPriority
{
totalMilliCPU
:=
nodeInfo
.
NonZeroRequest
()
.
MilliCPU
totalMilliCPU
:=
nodeInfo
.
NonZeroRequest
()
.
MilliCPU
totalMemory
:=
nodeInfo
.
NonZeroRequest
()
.
Memory
totalMemory
:=
nodeInfo
.
NonZeroRequest
()
.
Memory
score
:=
int
(
0
)
score
:=
int
(
0
)
...
...
plugin/pkg/scheduler/algorithm/priorities/taint_toleration.go
View file @
6c77c01f
...
@@ -83,7 +83,8 @@ func (s *TaintToleration) ComputeTaintTolerationPriority(pod *api.Pod, nodeNameT
...
@@ -83,7 +83,8 @@ func (s *TaintToleration) ComputeTaintTolerationPriority(pod *api.Pod, nodeNameT
tolerationList
:=
getAllTolerationPreferNoSchedule
(
tolerations
)
tolerationList
:=
getAllTolerationPreferNoSchedule
(
tolerations
)
// calculate the intolerable taints for all the nodes
// calculate the intolerable taints for all the nodes
for
_
,
node
:=
range
nodes
.
Items
{
for
i
:=
range
nodes
.
Items
{
node
:=
&
nodes
.
Items
[
i
]
taints
,
err
:=
api
.
GetTaintsFromNodeAnnotations
(
node
.
Annotations
)
taints
,
err
:=
api
.
GetTaintsFromNodeAnnotations
(
node
.
Annotations
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
...
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