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
d02e8d28
Commit
d02e8d28
authored
Jul 11, 2016
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid unnecessary conversions
parent
dcb2ca54
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
14 deletions
+23
-14
node_affinity.go
plugin/pkg/scheduler/algorithm/priorities/node_affinity.go
+12
-7
taint_toleration.go
...in/pkg/scheduler/algorithm/priorities/taint_toleration.go
+11
-7
No files found.
plugin/pkg/scheduler/algorithm/priorities/node_affinity.go
View file @
d02e8d28
...
...
@@ -36,8 +36,8 @@ func CalculateNodeAffinityPriority(pod *api.Pod, nodeNameToInfo map[string]*sche
return
nil
,
err
}
var
maxCount
int
counts
:=
make
(
map
[
string
]
int
,
len
(
nodes
.
Items
))
var
maxCount
float64
counts
:=
make
(
map
[
string
]
float64
,
len
(
nodes
.
Items
))
affinity
,
err
:=
api
.
GetAffinityFromPodAnnotations
(
pod
.
Annotations
)
if
err
!=
nil
{
...
...
@@ -61,7 +61,7 @@ func CalculateNodeAffinityPriority(pod *api.Pod, nodeNameToInfo map[string]*sche
for
_
,
node
:=
range
nodes
.
Items
{
if
nodeSelector
.
Matches
(
labels
.
Set
(
node
.
Labels
))
{
counts
[
node
.
Name
]
+=
int
(
preferredSchedulingTerm
.
Weight
)
counts
[
node
.
Name
]
+=
float64
(
preferredSchedulingTerm
.
Weight
)
}
if
counts
[
node
.
Name
]
>
maxCount
{
...
...
@@ -74,12 +74,17 @@ func CalculateNodeAffinityPriority(pod *api.Pod, nodeNameToInfo map[string]*sche
result
:=
make
(
schedulerapi
.
HostPriorityList
,
0
,
len
(
nodes
.
Items
))
for
i
:=
range
nodes
.
Items
{
node
:=
&
nodes
.
Items
[
i
]
fScore
:=
float64
(
0
)
if
maxCount
>
0
{
fScore
=
10
*
(
float64
(
counts
[
node
.
Name
])
/
float64
(
maxCount
))
fScore
:=
10
*
(
counts
[
node
.
Name
]
/
maxCount
)
result
=
append
(
result
,
schedulerapi
.
HostPriority
{
Host
:
node
.
Name
,
Score
:
int
(
fScore
)})
if
glog
.
V
(
10
)
{
// We explicitly don't do glog.V(10).Infof() to avoid computing all the parameters if this is
// not logged. There is visible performance gain from it.
glog
.
Infof
(
"%v -> %v: NodeAffinityPriority, Score: (%d)"
,
pod
.
Name
,
node
.
Name
,
int
(
fScore
))
}
}
else
{
result
=
append
(
result
,
schedulerapi
.
HostPriority
{
Host
:
node
.
Name
,
Score
:
0
})
}
result
=
append
(
result
,
schedulerapi
.
HostPriority
{
Host
:
node
.
Name
,
Score
:
int
(
fScore
)})
glog
.
V
(
10
)
.
Infof
(
"%v -> %v: NodeAffinityPriority, Score: (%d)"
,
pod
.
Name
,
node
.
Name
,
int
(
fScore
))
}
return
result
,
nil
}
plugin/pkg/scheduler/algorithm/priorities/taint_toleration.go
View file @
d02e8d28
...
...
@@ -25,7 +25,7 @@ import (
)
// CountIntolerableTaintsPreferNoSchedule gives the count of intolerable taints of a pod with effect PreferNoSchedule
func
countIntolerableTaintsPreferNoSchedule
(
taints
[]
api
.
Taint
,
tolerations
[]
api
.
Toleration
)
(
intolerableTaints
int
)
{
func
countIntolerableTaintsPreferNoSchedule
(
taints
[]
api
.
Taint
,
tolerations
[]
api
.
Toleration
)
(
intolerableTaints
float64
)
{
for
i
:=
range
taints
{
taint
:=
&
taints
[
i
]
// check only on taints that have effect PreferNoSchedule
...
...
@@ -59,9 +59,9 @@ func ComputeTaintTolerationPriority(pod *api.Pod, nodeNameToInfo map[string]*sch
}
// the max value of counts
var
maxCount
int
var
maxCount
float64
// counts hold the count of intolerable taints of a pod for a given node
counts
:=
make
(
map
[
string
]
int
,
len
(
nodes
.
Items
))
counts
:=
make
(
map
[
string
]
float64
,
len
(
nodes
.
Items
))
tolerations
,
err
:=
api
.
GetTolerationsFromPodAnnotations
(
pod
.
Annotations
)
if
err
!=
nil
{
...
...
@@ -87,15 +87,19 @@ func ComputeTaintTolerationPriority(pod *api.Pod, nodeNameToInfo map[string]*sch
// The maximum priority value to give to a node
// Priority values range from 0 - maxPriority
const
maxPriority
=
10
const
maxPriority
=
float64
(
10
)
result
:=
make
(
schedulerapi
.
HostPriorityList
,
0
,
len
(
nodes
.
Items
))
for
i
:=
range
nodes
.
Items
{
node
:=
&
nodes
.
Items
[
i
]
fScore
:=
float64
(
maxPriority
)
fScore
:=
maxPriority
if
maxCount
>
0
{
fScore
=
(
1.0
-
float64
(
counts
[
node
.
Name
])
/
float64
(
maxCount
))
*
10
fScore
=
(
1.0
-
counts
[
node
.
Name
]
/
maxCount
)
*
10
}
if
glog
.
V
(
10
)
{
// We explicitly don't do glog.V(10).Infof() to avoid computing all the parameters if this is
// not logged. There is visible performance gain from it.
glog
.
Infof
(
"%v -> %v: Taint Toleration Priority, Score: (%d)"
,
pod
.
Name
,
node
.
Name
,
int
(
fScore
))
}
glog
.
V
(
10
)
.
Infof
(
"%v -> %v: Taint Toleration Priority, Score: (%d)"
,
pod
.
Name
,
node
.
Name
,
int
(
fScore
))
result
=
append
(
result
,
schedulerapi
.
HostPriority
{
Host
:
node
.
Name
,
Score
:
int
(
fScore
)})
}
...
...
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