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
d14fe0f2
Commit
d14fe0f2
authored
Jul 11, 2016
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change storeToNodeConditionLister to return []*api.Node instead of api.NodeList for performance
parent
9b74e24f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
141 additions
and
125 deletions
+141
-125
listers.go
pkg/client/cache/listers.go
+2
-2
listers_test.go
pkg/client/cache/listers_test.go
+3
-3
servicecontroller.go
pkg/controller/service/servicecontroller.go
+17
-4
listers.go
plugin/pkg/scheduler/algorithm/listers.go
+8
-5
interpod_affinity.go
...n/pkg/scheduler/algorithm/priorities/interpod_affinity.go
+7
-7
interpod_affinity_test.go
.../scheduler/algorithm/priorities/interpod_affinity_test.go
+0
-0
node_affinity.go
plugin/pkg/scheduler/algorithm/priorities/node_affinity.go
+4
-5
node_affinity_test.go
.../pkg/scheduler/algorithm/priorities/node_affinity_test.go
+6
-6
priorities.go
plugin/pkg/scheduler/algorithm/priorities/priorities.go
+8
-11
priorities_test.go
plugin/pkg/scheduler/algorithm/priorities/priorities_test.go
+0
-0
selector_spreading.go
.../pkg/scheduler/algorithm/priorities/selector_spreading.go
+8
-10
selector_spreading_test.go
...scheduler/algorithm/priorities/selector_spreading_test.go
+9
-11
taint_toleration.go
...in/pkg/scheduler/algorithm/priorities/taint_toleration.go
+4
-6
taint_toleration_test.go
...g/scheduler/algorithm/priorities/taint_toleration_test.go
+8
-8
scheduler_interface.go
plugin/pkg/scheduler/algorithm/scheduler_interface.go
+2
-2
extender.go
plugin/pkg/scheduler/extender.go
+18
-6
extender_test.go
plugin/pkg/scheduler/extender_test.go
+14
-14
generic_scheduler.go
plugin/pkg/scheduler/generic_scheduler.go
+16
-16
generic_scheduler_test.go
plugin/pkg/scheduler/generic_scheduler_test.go
+5
-7
scheduler_test.go
plugin/pkg/scheduler/scheduler_test.go
+2
-2
No files found.
pkg/client/cache/listers.go
View file @
d14fe0f2
...
@@ -151,11 +151,11 @@ type storeToNodeConditionLister struct {
...
@@ -151,11 +151,11 @@ type storeToNodeConditionLister struct {
}
}
// List returns a list of nodes that match the conditions defined by the predicate functions in the storeToNodeConditionLister.
// List returns a list of nodes that match the conditions defined by the predicate functions in the storeToNodeConditionLister.
func
(
s
storeToNodeConditionLister
)
List
()
(
nodes
api
.
NodeList
,
err
error
)
{
func
(
s
storeToNodeConditionLister
)
List
()
(
nodes
[]
*
api
.
Node
,
err
error
)
{
for
_
,
m
:=
range
s
.
store
.
List
()
{
for
_
,
m
:=
range
s
.
store
.
List
()
{
node
:=
m
.
(
*
api
.
Node
)
node
:=
m
.
(
*
api
.
Node
)
if
s
.
predicate
(
node
)
{
if
s
.
predicate
(
node
)
{
nodes
.
Items
=
append
(
nodes
.
Items
,
*
node
)
nodes
=
append
(
nodes
,
node
)
}
else
{
}
else
{
glog
.
V
(
5
)
.
Infof
(
"Node %s matches none of the conditions"
,
node
.
Name
)
glog
.
V
(
5
)
.
Infof
(
"Node %s matches none of the conditions"
,
node
.
Name
)
}
}
...
...
pkg/client/cache/listers_test.go
View file @
d14fe0f2
...
@@ -114,9 +114,9 @@ func TestStoreToNodeConditionLister(t *testing.T) {
...
@@ -114,9 +114,9 @@ func TestStoreToNodeConditionLister(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
}
}
got
:=
make
([]
string
,
len
(
gotNodes
.
Items
))
got
:=
make
([]
string
,
len
(
gotNodes
))
for
ix
:=
range
gotNodes
.
Items
{
for
ix
:=
range
gotNodes
{
got
[
ix
]
=
gotNodes
.
Items
[
ix
]
.
Name
got
[
ix
]
=
gotNodes
[
ix
]
.
Name
}
}
if
!
want
.
HasAll
(
got
...
)
||
len
(
got
)
!=
len
(
want
)
{
if
!
want
.
HasAll
(
got
...
)
||
len
(
got
)
!=
len
(
want
)
{
t
.
Errorf
(
"Expected %v, got %v"
,
want
,
got
)
t
.
Errorf
(
"Expected %v, got %v"
,
want
,
got
)
...
...
pkg/controller/service/servicecontroller.go
View file @
d14fe0f2
...
@@ -629,13 +629,26 @@ func stringSlicesEqual(x, y []string) bool {
...
@@ -629,13 +629,26 @@ func stringSlicesEqual(x, y []string) bool {
return
true
return
true
}
}
func
includeNodeFromNodeList
(
node
*
api
.
Node
)
bool
{
return
!
node
.
Spec
.
Unschedulable
}
func
hostsFromNodeList
(
list
*
api
.
NodeList
)
[]
string
{
func
hostsFromNodeList
(
list
*
api
.
NodeList
)
[]
string
{
result
:=
[]
string
{}
result
:=
[]
string
{}
for
ix
:=
range
list
.
Items
{
for
ix
:=
range
list
.
Items
{
if
list
.
Items
[
ix
]
.
Spec
.
Unschedulable
{
if
includeNodeFromNodeList
(
&
list
.
Items
[
ix
])
{
continue
result
=
append
(
result
,
list
.
Items
[
ix
]
.
Name
)
}
}
return
result
}
func
hostsFromNodeSlice
(
nodes
[]
*
api
.
Node
)
[]
string
{
result
:=
[]
string
{}
for
_
,
node
:=
range
nodes
{
if
includeNodeFromNodeList
(
node
)
{
result
=
append
(
result
,
node
.
Name
)
}
}
result
=
append
(
result
,
list
.
Items
[
ix
]
.
Name
)
}
}
return
result
return
result
}
}
...
@@ -675,7 +688,7 @@ func (s *ServiceController) nodeSyncLoop(period time.Duration) {
...
@@ -675,7 +688,7 @@ func (s *ServiceController) nodeSyncLoop(period time.Duration) {
glog
.
Errorf
(
"Failed to retrieve current set of nodes from node lister: %v"
,
err
)
glog
.
Errorf
(
"Failed to retrieve current set of nodes from node lister: %v"
,
err
)
continue
continue
}
}
newHosts
:=
hostsFromNode
List
(
&
nodes
)
newHosts
:=
hostsFromNode
Slice
(
nodes
)
if
stringSlicesEqual
(
newHosts
,
prevHosts
)
{
if
stringSlicesEqual
(
newHosts
,
prevHosts
)
{
// The set of nodes in the cluster hasn't changed, but we can retry
// The set of nodes in the cluster hasn't changed, but we can retry
// updating any services that we failed to update last time around.
// updating any services that we failed to update last time around.
...
...
plugin/pkg/scheduler/algorithm/listers.go
View file @
d14fe0f2
...
@@ -27,20 +27,23 @@ import (
...
@@ -27,20 +27,23 @@ import (
// NodeLister interface represents anything that can list nodes for a scheduler.
// NodeLister interface represents anything that can list nodes for a scheduler.
type
NodeLister
interface
{
type
NodeLister
interface
{
List
()
(
list
api
.
NodeList
,
err
error
)
// We explicitly return []*api.Node, instead of api.NodeList, to avoid
// performing expensive copies that are unneded.
List
()
([]
*
api
.
Node
,
error
)
}
}
// FakeNodeLister implements NodeLister on a []string for test purposes.
// FakeNodeLister implements NodeLister on a []string for test purposes.
type
FakeNodeLister
api
.
NodeList
type
FakeNodeLister
[]
*
api
.
Node
// List returns nodes as a []string.
// List returns nodes as a []string.
func
(
f
FakeNodeLister
)
List
()
(
api
.
NodeList
,
error
)
{
func
(
f
FakeNodeLister
)
List
()
(
[]
*
api
.
Node
,
error
)
{
return
api
.
NodeList
(
f
)
,
nil
return
f
,
nil
}
}
// PodLister interface represents anything that can list pods for a scheduler.
// PodLister interface represents anything that can list pods for a scheduler.
type
PodLister
interface
{
type
PodLister
interface
{
// TODO: make this exactly the same as client's Pods(ns).List() method, by returning a api.PodList
// We explicitly return []*api.Pod, instead of api.PodList, to avoid
// performing expensive copies that are unneded.
List
(
labels
.
Selector
)
([]
*
api
.
Pod
,
error
)
List
(
labels
.
Selector
)
([]
*
api
.
Pod
,
error
)
}
}
...
...
plugin/pkg/scheduler/algorithm/priorities/interpod_affinity.go
View file @
d14fe0f2
...
@@ -101,12 +101,12 @@ func (ipa *InterPodAffinity) CalculateInterPodAffinityPriority(pod *api.Pod, nod
...
@@ -101,12 +101,12 @@ func (ipa *InterPodAffinity) CalculateInterPodAffinityPriority(pod *api.Pod, nod
var
maxCount
int
var
maxCount
int
var
minCount
int
var
minCount
int
counts
:=
map
[
string
]
int
{}
counts
:=
map
[
string
]
int
{}
for
_
,
node
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
{
totalCount
:=
0
totalCount
:=
0
// count weights for the weighted pod affinity
// count weights for the weighted pod affinity
if
affinity
.
PodAffinity
!=
nil
{
if
affinity
.
PodAffinity
!=
nil
{
for
_
,
weightedTerm
:=
range
affinity
.
PodAffinity
.
PreferredDuringSchedulingIgnoredDuringExecution
{
for
_
,
weightedTerm
:=
range
affinity
.
PodAffinity
.
PreferredDuringSchedulingIgnoredDuringExecution
{
weightedCount
,
err
:=
ipa
.
CountWeightByPodMatchAffinityTerm
(
pod
,
allPods
,
weightedTerm
.
Weight
,
weightedTerm
.
PodAffinityTerm
,
&
node
)
weightedCount
,
err
:=
ipa
.
CountWeightByPodMatchAffinityTerm
(
pod
,
allPods
,
weightedTerm
.
Weight
,
weightedTerm
.
PodAffinityTerm
,
node
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -117,7 +117,7 @@ func (ipa *InterPodAffinity) CalculateInterPodAffinityPriority(pod *api.Pod, nod
...
@@ -117,7 +117,7 @@ func (ipa *InterPodAffinity) CalculateInterPodAffinityPriority(pod *api.Pod, nod
// count weights for the weighted pod anti-affinity
// count weights for the weighted pod anti-affinity
if
affinity
.
PodAntiAffinity
!=
nil
{
if
affinity
.
PodAntiAffinity
!=
nil
{
for
_
,
weightedTerm
:=
range
affinity
.
PodAntiAffinity
.
PreferredDuringSchedulingIgnoredDuringExecution
{
for
_
,
weightedTerm
:=
range
affinity
.
PodAntiAffinity
.
PreferredDuringSchedulingIgnoredDuringExecution
{
weightedCount
,
err
:=
ipa
.
CountWeightByPodMatchAffinityTerm
(
pod
,
allPods
,
(
0
-
weightedTerm
.
Weight
),
weightedTerm
.
PodAffinityTerm
,
&
node
)
weightedCount
,
err
:=
ipa
.
CountWeightByPodMatchAffinityTerm
(
pod
,
allPods
,
(
0
-
weightedTerm
.
Weight
),
weightedTerm
.
PodAffinityTerm
,
node
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -146,7 +146,7 @@ func (ipa *InterPodAffinity) CalculateInterPodAffinityPriority(pod *api.Pod, nod
...
@@ -146,7 +146,7 @@ func (ipa *InterPodAffinity) CalculateInterPodAffinityPriority(pod *api.Pod, nod
//}
//}
for
_
,
epAffinityTerm
:=
range
podAffinityTerms
{
for
_
,
epAffinityTerm
:=
range
podAffinityTerms
{
match
,
err
:=
ipa
.
failureDomains
.
CheckIfPodMatchPodAffinityTerm
(
pod
,
ep
,
epAffinityTerm
,
match
,
err
:=
ipa
.
failureDomains
.
CheckIfPodMatchPodAffinityTerm
(
pod
,
ep
,
epAffinityTerm
,
func
(
pod
*
api
.
Pod
)
(
*
api
.
Node
,
error
)
{
return
&
node
,
nil
},
func
(
pod
*
api
.
Pod
)
(
*
api
.
Node
,
error
)
{
return
node
,
nil
},
func
(
ep
*
api
.
Pod
)
(
*
api
.
Node
,
error
)
{
return
ipa
.
info
.
GetNodeInfo
(
ep
.
Spec
.
NodeName
)
},
func
(
ep
*
api
.
Pod
)
(
*
api
.
Node
,
error
)
{
return
ipa
.
info
.
GetNodeInfo
(
ep
.
Spec
.
NodeName
)
},
)
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -161,7 +161,7 @@ func (ipa *InterPodAffinity) CalculateInterPodAffinityPriority(pod *api.Pod, nod
...
@@ -161,7 +161,7 @@ func (ipa *InterPodAffinity) CalculateInterPodAffinityPriority(pod *api.Pod, nod
// count weight for the weighted pod affinity indicated by the existing pod.
// count weight for the weighted pod affinity indicated by the existing pod.
for
_
,
epWeightedTerm
:=
range
epAffinity
.
PodAffinity
.
PreferredDuringSchedulingIgnoredDuringExecution
{
for
_
,
epWeightedTerm
:=
range
epAffinity
.
PodAffinity
.
PreferredDuringSchedulingIgnoredDuringExecution
{
match
,
err
:=
ipa
.
failureDomains
.
CheckIfPodMatchPodAffinityTerm
(
pod
,
ep
,
epWeightedTerm
.
PodAffinityTerm
,
match
,
err
:=
ipa
.
failureDomains
.
CheckIfPodMatchPodAffinityTerm
(
pod
,
ep
,
epWeightedTerm
.
PodAffinityTerm
,
func
(
pod
*
api
.
Pod
)
(
*
api
.
Node
,
error
)
{
return
&
node
,
nil
},
func
(
pod
*
api
.
Pod
)
(
*
api
.
Node
,
error
)
{
return
node
,
nil
},
func
(
ep
*
api
.
Pod
)
(
*
api
.
Node
,
error
)
{
return
ipa
.
info
.
GetNodeInfo
(
ep
.
Spec
.
NodeName
)
},
func
(
ep
*
api
.
Pod
)
(
*
api
.
Node
,
error
)
{
return
ipa
.
info
.
GetNodeInfo
(
ep
.
Spec
.
NodeName
)
},
)
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -177,7 +177,7 @@ func (ipa *InterPodAffinity) CalculateInterPodAffinityPriority(pod *api.Pod, nod
...
@@ -177,7 +177,7 @@ func (ipa *InterPodAffinity) CalculateInterPodAffinityPriority(pod *api.Pod, nod
if
epAffinity
.
PodAntiAffinity
!=
nil
{
if
epAffinity
.
PodAntiAffinity
!=
nil
{
for
_
,
epWeightedTerm
:=
range
epAffinity
.
PodAntiAffinity
.
PreferredDuringSchedulingIgnoredDuringExecution
{
for
_
,
epWeightedTerm
:=
range
epAffinity
.
PodAntiAffinity
.
PreferredDuringSchedulingIgnoredDuringExecution
{
match
,
err
:=
ipa
.
failureDomains
.
CheckIfPodMatchPodAffinityTerm
(
pod
,
ep
,
epWeightedTerm
.
PodAffinityTerm
,
match
,
err
:=
ipa
.
failureDomains
.
CheckIfPodMatchPodAffinityTerm
(
pod
,
ep
,
epWeightedTerm
.
PodAffinityTerm
,
func
(
pod
*
api
.
Pod
)
(
*
api
.
Node
,
error
)
{
return
&
node
,
nil
},
func
(
pod
*
api
.
Pod
)
(
*
api
.
Node
,
error
)
{
return
node
,
nil
},
func
(
ep
*
api
.
Pod
)
(
*
api
.
Node
,
error
)
{
return
ipa
.
info
.
GetNodeInfo
(
ep
.
Spec
.
NodeName
)
},
func
(
ep
*
api
.
Pod
)
(
*
api
.
Node
,
error
)
{
return
ipa
.
info
.
GetNodeInfo
(
ep
.
Spec
.
NodeName
)
},
)
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -201,7 +201,7 @@ func (ipa *InterPodAffinity) CalculateInterPodAffinityPriority(pod *api.Pod, nod
...
@@ -201,7 +201,7 @@ func (ipa *InterPodAffinity) CalculateInterPodAffinityPriority(pod *api.Pod, nod
// calculate final priority score for each node
// calculate final priority score for each node
result
:=
[]
schedulerapi
.
HostPriority
{}
result
:=
[]
schedulerapi
.
HostPriority
{}
for
_
,
node
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
{
fScore
:=
float64
(
0
)
fScore
:=
float64
(
0
)
if
(
maxCount
-
minCount
)
>
0
{
if
(
maxCount
-
minCount
)
>
0
{
fScore
=
10
*
(
float64
(
counts
[
node
.
Name
]
-
minCount
)
/
float64
(
maxCount
-
minCount
))
fScore
=
10
*
(
float64
(
counts
[
node
.
Name
]
-
minCount
)
/
float64
(
maxCount
-
minCount
))
...
...
plugin/pkg/scheduler/algorithm/priorities/interpod_affinity_test.go
View file @
d14fe0f2
This diff is collapsed.
Click to expand it.
plugin/pkg/scheduler/algorithm/priorities/node_affinity.go
View file @
d14fe0f2
...
@@ -37,7 +37,7 @@ func CalculateNodeAffinityPriority(pod *api.Pod, nodeNameToInfo map[string]*sche
...
@@ -37,7 +37,7 @@ func CalculateNodeAffinityPriority(pod *api.Pod, nodeNameToInfo map[string]*sche
}
}
var
maxCount
float64
var
maxCount
float64
counts
:=
make
(
map
[
string
]
float64
,
len
(
nodes
.
Items
))
counts
:=
make
(
map
[
string
]
float64
,
len
(
nodes
))
affinity
,
err
:=
api
.
GetAffinityFromPodAnnotations
(
pod
.
Annotations
)
affinity
,
err
:=
api
.
GetAffinityFromPodAnnotations
(
pod
.
Annotations
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -59,7 +59,7 @@ func CalculateNodeAffinityPriority(pod *api.Pod, nodeNameToInfo map[string]*sche
...
@@ -59,7 +59,7 @@ func CalculateNodeAffinityPriority(pod *api.Pod, nodeNameToInfo map[string]*sche
return
nil
,
err
return
nil
,
err
}
}
for
_
,
node
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
{
if
nodeSelector
.
Matches
(
labels
.
Set
(
node
.
Labels
))
{
if
nodeSelector
.
Matches
(
labels
.
Set
(
node
.
Labels
))
{
counts
[
node
.
Name
]
+=
float64
(
preferredSchedulingTerm
.
Weight
)
counts
[
node
.
Name
]
+=
float64
(
preferredSchedulingTerm
.
Weight
)
}
}
...
@@ -71,9 +71,8 @@ func CalculateNodeAffinityPriority(pod *api.Pod, nodeNameToInfo map[string]*sche
...
@@ -71,9 +71,8 @@ func CalculateNodeAffinityPriority(pod *api.Pod, nodeNameToInfo map[string]*sche
}
}
}
}
result
:=
make
(
schedulerapi
.
HostPriorityList
,
0
,
len
(
nodes
.
Items
))
result
:=
make
(
schedulerapi
.
HostPriorityList
,
0
,
len
(
nodes
))
for
i
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
{
node
:=
&
nodes
.
Items
[
i
]
if
maxCount
>
0
{
if
maxCount
>
0
{
fScore
:=
10
*
(
counts
[
node
.
Name
]
/
maxCount
)
fScore
:=
10
*
(
counts
[
node
.
Name
]
/
maxCount
)
result
=
append
(
result
,
schedulerapi
.
HostPriority
{
Host
:
node
.
Name
,
Score
:
int
(
fScore
)})
result
=
append
(
result
,
schedulerapi
.
HostPriority
{
Host
:
node
.
Name
,
Score
:
int
(
fScore
)})
...
...
plugin/pkg/scheduler/algorithm/priorities/node_affinity_test.go
View file @
d14fe0f2
...
@@ -93,7 +93,7 @@ func TestNodeAffinityPriority(t *testing.T) {
...
@@ -93,7 +93,7 @@ func TestNodeAffinityPriority(t *testing.T) {
tests
:=
[]
struct
{
tests
:=
[]
struct
{
pod
*
api
.
Pod
pod
*
api
.
Pod
nodes
[]
api
.
Node
nodes
[]
*
api
.
Node
expectedList
schedulerapi
.
HostPriorityList
expectedList
schedulerapi
.
HostPriorityList
test
string
test
string
}{
}{
...
@@ -103,7 +103,7 @@ func TestNodeAffinityPriority(t *testing.T) {
...
@@ -103,7 +103,7 @@ func TestNodeAffinityPriority(t *testing.T) {
Annotations
:
map
[
string
]
string
{},
Annotations
:
map
[
string
]
string
{},
},
},
},
},
nodes
:
[]
api
.
Node
{
nodes
:
[]
*
api
.
Node
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine1"
,
Labels
:
label1
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine1"
,
Labels
:
label1
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine2"
,
Labels
:
label2
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine2"
,
Labels
:
label2
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine3"
,
Labels
:
label3
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine3"
,
Labels
:
label3
}},
...
@@ -117,7 +117,7 @@ func TestNodeAffinityPriority(t *testing.T) {
...
@@ -117,7 +117,7 @@ func TestNodeAffinityPriority(t *testing.T) {
Annotations
:
affinity1
,
Annotations
:
affinity1
,
},
},
},
},
nodes
:
[]
api
.
Node
{
nodes
:
[]
*
api
.
Node
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine1"
,
Labels
:
label4
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine1"
,
Labels
:
label4
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine2"
,
Labels
:
label2
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine2"
,
Labels
:
label2
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine3"
,
Labels
:
label3
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine3"
,
Labels
:
label3
}},
...
@@ -131,7 +131,7 @@ func TestNodeAffinityPriority(t *testing.T) {
...
@@ -131,7 +131,7 @@ func TestNodeAffinityPriority(t *testing.T) {
Annotations
:
affinity1
,
Annotations
:
affinity1
,
},
},
},
},
nodes
:
[]
api
.
Node
{
nodes
:
[]
*
api
.
Node
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine1"
,
Labels
:
label1
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine1"
,
Labels
:
label1
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine2"
,
Labels
:
label2
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine2"
,
Labels
:
label2
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine3"
,
Labels
:
label3
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine3"
,
Labels
:
label3
}},
...
@@ -145,7 +145,7 @@ func TestNodeAffinityPriority(t *testing.T) {
...
@@ -145,7 +145,7 @@ func TestNodeAffinityPriority(t *testing.T) {
Annotations
:
affinity2
,
Annotations
:
affinity2
,
},
},
},
},
nodes
:
[]
api
.
Node
{
nodes
:
[]
*
api
.
Node
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine1"
,
Labels
:
label1
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine1"
,
Labels
:
label1
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine5"
,
Labels
:
label5
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine5"
,
Labels
:
label5
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine2"
,
Labels
:
label2
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine2"
,
Labels
:
label2
}},
...
@@ -156,7 +156,7 @@ func TestNodeAffinityPriority(t *testing.T) {
...
@@ -156,7 +156,7 @@ func TestNodeAffinityPriority(t *testing.T) {
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
list
,
err
:=
CalculateNodeAffinityPriority
(
test
.
pod
,
schedulercache
.
CreateNodeNameToInfoMap
(
nil
),
algorithm
.
FakeNodeLister
(
api
.
NodeList
{
Items
:
test
.
nodes
}
))
list
,
err
:=
CalculateNodeAffinityPriority
(
test
.
pod
,
schedulercache
.
CreateNodeNameToInfoMap
(
nil
),
algorithm
.
FakeNodeLister
(
test
.
nodes
))
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
...
...
plugin/pkg/scheduler/algorithm/priorities/priorities.go
View file @
d14fe0f2
...
@@ -86,9 +86,8 @@ func LeastRequestedPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulerca
...
@@ -86,9 +86,8 @@ func LeastRequestedPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulerca
return
schedulerapi
.
HostPriorityList
{},
err
return
schedulerapi
.
HostPriorityList
{},
err
}
}
list
:=
make
(
schedulerapi
.
HostPriorityList
,
0
,
len
(
nodes
.
Items
))
list
:=
make
(
schedulerapi
.
HostPriorityList
,
0
,
len
(
nodes
))
for
i
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
{
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
...
@@ -118,12 +117,12 @@ func (n *NodeLabelPrioritizer) CalculateNodeLabelPriority(pod *api.Pod, nodeName
...
@@ -118,12 +117,12 @@ func (n *NodeLabelPrioritizer) CalculateNodeLabelPriority(pod *api.Pod, nodeName
}
}
labeledNodes
:=
map
[
string
]
bool
{}
labeledNodes
:=
map
[
string
]
bool
{}
for
_
,
node
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
{
exists
:=
labels
.
Set
(
node
.
Labels
)
.
Has
(
n
.
label
)
exists
:=
labels
.
Set
(
node
.
Labels
)
.
Has
(
n
.
label
)
labeledNodes
[
node
.
Name
]
=
(
exists
&&
n
.
presence
)
||
(
!
exists
&&
!
n
.
presence
)
labeledNodes
[
node
.
Name
]
=
(
exists
&&
n
.
presence
)
||
(
!
exists
&&
!
n
.
presence
)
}
}
result
:=
make
(
schedulerapi
.
HostPriorityList
,
0
,
len
(
nodes
.
Items
))
result
:=
make
(
schedulerapi
.
HostPriorityList
,
0
,
len
(
nodes
))
//score int - scale of 0-10
//score int - scale of 0-10
// 0 being the lowest priority and 10 being the highest
// 0 being the lowest priority and 10 being the highest
for
nodeName
,
success
:=
range
labeledNodes
{
for
nodeName
,
success
:=
range
labeledNodes
{
...
@@ -158,8 +157,7 @@ func ImageLocalityPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulercac
...
@@ -158,8 +157,7 @@ func ImageLocalityPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulercac
}
}
for
i
:=
range
pod
.
Spec
.
Containers
{
for
i
:=
range
pod
.
Spec
.
Containers
{
for
j
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
{
node
:=
&
nodes
.
Items
[
j
]
// 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
,
&
pod
.
Spec
.
Containers
[
i
])
imageSize
:=
checkContainerImageOnNode
(
node
,
&
pod
.
Spec
.
Containers
[
i
])
// Add this size to the total result of this node.
// Add this size to the total result of this node.
...
@@ -167,7 +165,7 @@ func ImageLocalityPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulercac
...
@@ -167,7 +165,7 @@ func ImageLocalityPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulercac
}
}
}
}
result
:=
make
(
schedulerapi
.
HostPriorityList
,
0
,
len
(
nodes
.
Items
))
result
:=
make
(
schedulerapi
.
HostPriorityList
,
0
,
len
(
nodes
))
// score int - scale of 0-10
// score int - scale of 0-10
// 0 being the lowest priority and 10 being the highest.
// 0 being the lowest priority and 10 being the highest.
for
nodeName
,
sumSize
:=
range
sumSizeMap
{
for
nodeName
,
sumSize
:=
range
sumSizeMap
{
...
@@ -222,9 +220,8 @@ func BalancedResourceAllocation(pod *api.Pod, nodeNameToInfo map[string]*schedul
...
@@ -222,9 +220,8 @@ func BalancedResourceAllocation(pod *api.Pod, nodeNameToInfo map[string]*schedul
return
schedulerapi
.
HostPriorityList
{},
err
return
schedulerapi
.
HostPriorityList
{},
err
}
}
list
:=
make
(
schedulerapi
.
HostPriorityList
,
0
,
len
(
nodes
.
Items
))
list
:=
make
(
schedulerapi
.
HostPriorityList
,
0
,
len
(
nodes
))
for
i
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
{
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
...
...
plugin/pkg/scheduler/algorithm/priorities/priorities_test.go
View file @
d14fe0f2
This diff is collapsed.
Click to expand it.
plugin/pkg/scheduler/algorithm/priorities/selector_spreading.go
View file @
d14fe0f2
...
@@ -117,12 +117,13 @@ func (s *SelectorSpread) CalculateSpreadPriority(pod *api.Pod, nodeNameToInfo ma
...
@@ -117,12 +117,13 @@ func (s *SelectorSpread) CalculateSpreadPriority(pod *api.Pod, nodeNameToInfo ma
// Create a number of go-routines that will be computing number
// Create a number of go-routines that will be computing number
// of "similar" pods for given nodes.
// of "similar" pods for given nodes.
workers
:=
16
workers
:=
16
toProcess
:=
make
(
chan
string
,
len
(
nodes
.
Items
))
toProcess
:=
make
(
chan
string
,
len
(
nodes
))
for
i
:=
range
nodes
.
Items
{
for
i
:=
range
nodes
{
toProcess
<-
nodes
.
Items
[
i
]
.
Name
toProcess
<-
nodes
[
i
]
.
Name
}
}
close
(
toProcess
)
close
(
toProcess
)
// TODO: Use Parallelize.
wg
:=
sync
.
WaitGroup
{}
wg
:=
sync
.
WaitGroup
{}
wg
.
Add
(
workers
)
wg
.
Add
(
workers
)
for
i
:=
0
;
i
<
workers
;
i
++
{
for
i
:=
0
;
i
<
workers
;
i
++
{
...
@@ -181,9 +182,7 @@ func (s *SelectorSpread) CalculateSpreadPriority(pod *api.Pod, nodeNameToInfo ma
...
@@ -181,9 +182,7 @@ func (s *SelectorSpread) CalculateSpreadPriority(pod *api.Pod, nodeNameToInfo ma
// Count similar pods by zone, if zone information is present
// Count similar pods by zone, if zone information is present
countsByZone
:=
map
[
string
]
int
{}
countsByZone
:=
map
[
string
]
int
{}
for
i
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
{
node
:=
&
nodes
.
Items
[
i
]
count
,
found
:=
countsByNodeName
[
node
.
Name
]
count
,
found
:=
countsByNodeName
[
node
.
Name
]
if
!
found
{
if
!
found
{
continue
continue
...
@@ -207,11 +206,10 @@ func (s *SelectorSpread) CalculateSpreadPriority(pod *api.Pod, nodeNameToInfo ma
...
@@ -207,11 +206,10 @@ func (s *SelectorSpread) CalculateSpreadPriority(pod *api.Pod, nodeNameToInfo ma
}
}
}
}
result
:=
make
(
schedulerapi
.
HostPriorityList
,
0
,
len
(
nodes
.
Items
))
result
:=
make
(
schedulerapi
.
HostPriorityList
,
0
,
len
(
nodes
))
//score int - scale of 0-maxPriority
//score int - scale of 0-maxPriority
// 0 being the lowest priority and maxPriority being the highest
// 0 being the lowest priority and maxPriority being the highest
for
i
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
{
node
:=
&
nodes
.
Items
[
i
]
// initializing to the default/max node score of maxPriority
// initializing to the default/max node score of maxPriority
fScore
:=
float32
(
maxPriority
)
fScore
:=
float32
(
maxPriority
)
if
maxCountByNodeName
>
0
{
if
maxCountByNodeName
>
0
{
...
@@ -281,7 +279,7 @@ func (s *ServiceAntiAffinity) CalculateAntiAffinityPriority(pod *api.Pod, nodeNa
...
@@ -281,7 +279,7 @@ func (s *ServiceAntiAffinity) CalculateAntiAffinityPriority(pod *api.Pod, nodeNa
// separate out the nodes that have the label from the ones that don't
// separate out the nodes that have the label from the ones that don't
otherNodes
:=
[]
string
{}
otherNodes
:=
[]
string
{}
labeledNodes
:=
map
[
string
]
string
{}
labeledNodes
:=
map
[
string
]
string
{}
for
_
,
node
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
{
if
labels
.
Set
(
node
.
Labels
)
.
Has
(
s
.
label
)
{
if
labels
.
Set
(
node
.
Labels
)
.
Has
(
s
.
label
)
{
label
:=
labels
.
Set
(
node
.
Labels
)
.
Get
(
s
.
label
)
label
:=
labels
.
Set
(
node
.
Labels
)
.
Get
(
s
.
label
)
labeledNodes
[
node
.
Name
]
=
label
labeledNodes
[
node
.
Name
]
=
label
...
...
plugin/pkg/scheduler/algorithm/priorities/selector_spreading_test.go
View file @
d14fe0f2
...
@@ -664,20 +664,18 @@ func TestZoneSpreadPriority(t *testing.T) {
...
@@ -664,20 +664,18 @@ func TestZoneSpreadPriority(t *testing.T) {
}
}
}
}
func
makeLabeledNodeList
(
nodeMap
map
[
string
]
map
[
string
]
string
)
(
result
api
.
NodeList
)
{
func
makeLabeledNodeList
(
nodeMap
map
[
string
]
map
[
string
]
string
)
[]
*
api
.
Node
{
nodes
:=
[]
api
.
Node
{}
nodes
:=
make
([]
*
api
.
Node
,
0
,
len
(
nodeMap
))
for
nodeName
,
labels
:=
range
nodeMap
{
for
nodeName
,
labels
:=
range
nodeMap
{
nodes
=
append
(
nodes
,
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
nodeName
,
Labels
:
labels
}})
nodes
=
append
(
nodes
,
&
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
nodeName
,
Labels
:
labels
}})
}
}
return
api
.
NodeList
{
Items
:
nodes
}
return
nodes
}
}
func
makeNodeList
(
nodeNames
[]
string
)
api
.
NodeList
{
func
makeNodeList
(
nodeNames
[]
string
)
[]
*
api
.
Node
{
result
:=
api
.
NodeList
{
nodes
:=
make
([]
*
api
.
Node
,
0
,
len
(
nodeNames
))
Items
:
make
([]
api
.
Node
,
len
(
nodeNames
)),
for
_
,
nodeName
:=
range
nodeNames
{
nodes
=
append
(
nodes
,
&
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
nodeName
}})
}
}
for
ix
:=
range
nodeNames
{
return
nodes
result
.
Items
[
ix
]
.
Name
=
nodeNames
[
ix
]
}
return
result
}
}
plugin/pkg/scheduler/algorithm/priorities/taint_toleration.go
View file @
d14fe0f2
...
@@ -61,7 +61,7 @@ func ComputeTaintTolerationPriority(pod *api.Pod, nodeNameToInfo map[string]*sch
...
@@ -61,7 +61,7 @@ func ComputeTaintTolerationPriority(pod *api.Pod, nodeNameToInfo map[string]*sch
// the max value of counts
// the max value of counts
var
maxCount
float64
var
maxCount
float64
// counts hold the count of intolerable taints of a pod for a given node
// counts hold the count of intolerable taints of a pod for a given node
counts
:=
make
(
map
[
string
]
float64
,
len
(
nodes
.
Items
))
counts
:=
make
(
map
[
string
]
float64
,
len
(
nodes
))
tolerations
,
err
:=
api
.
GetTolerationsFromPodAnnotations
(
pod
.
Annotations
)
tolerations
,
err
:=
api
.
GetTolerationsFromPodAnnotations
(
pod
.
Annotations
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -71,8 +71,7 @@ func ComputeTaintTolerationPriority(pod *api.Pod, nodeNameToInfo map[string]*sch
...
@@ -71,8 +71,7 @@ func ComputeTaintTolerationPriority(pod *api.Pod, nodeNameToInfo map[string]*sch
tolerationList
:=
getAllTolerationPreferNoSchedule
(
tolerations
)
tolerationList
:=
getAllTolerationPreferNoSchedule
(
tolerations
)
// calculate the intolerable taints for all the nodes
// calculate the intolerable taints for all the nodes
for
i
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
{
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
...
@@ -88,9 +87,8 @@ func ComputeTaintTolerationPriority(pod *api.Pod, nodeNameToInfo map[string]*sch
...
@@ -88,9 +87,8 @@ func ComputeTaintTolerationPriority(pod *api.Pod, nodeNameToInfo map[string]*sch
// The maximum priority value to give to a node
// The maximum priority value to give to a node
// Priority values range from 0 - maxPriority
// Priority values range from 0 - maxPriority
const
maxPriority
=
float64
(
10
)
const
maxPriority
=
float64
(
10
)
result
:=
make
(
schedulerapi
.
HostPriorityList
,
0
,
len
(
nodes
.
Items
))
result
:=
make
(
schedulerapi
.
HostPriorityList
,
0
,
len
(
nodes
))
for
i
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
{
node
:=
&
nodes
.
Items
[
i
]
fScore
:=
maxPriority
fScore
:=
maxPriority
if
maxCount
>
0
{
if
maxCount
>
0
{
fScore
=
(
1.0
-
counts
[
node
.
Name
]
/
maxCount
)
*
10
fScore
=
(
1.0
-
counts
[
node
.
Name
]
/
maxCount
)
*
10
...
...
plugin/pkg/scheduler/algorithm/priorities/taint_toleration_test.go
View file @
d14fe0f2
...
@@ -27,9 +27,9 @@ import (
...
@@ -27,9 +27,9 @@ import (
"k8s.io/kubernetes/plugin/pkg/scheduler/schedulercache"
"k8s.io/kubernetes/plugin/pkg/scheduler/schedulercache"
)
)
func
nodeWithTaints
(
nodeName
string
,
taints
[]
api
.
Taint
)
api
.
Node
{
func
nodeWithTaints
(
nodeName
string
,
taints
[]
api
.
Taint
)
*
api
.
Node
{
taintsData
,
_
:=
json
.
Marshal
(
taints
)
taintsData
,
_
:=
json
.
Marshal
(
taints
)
return
api
.
Node
{
return
&
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
nodeName
,
Name
:
nodeName
,
Annotations
:
map
[
string
]
string
{
Annotations
:
map
[
string
]
string
{
...
@@ -57,7 +57,7 @@ func podWithTolerations(tolerations []api.Toleration) *api.Pod {
...
@@ -57,7 +57,7 @@ func podWithTolerations(tolerations []api.Toleration) *api.Pod {
func
TestTaintAndToleration
(
t
*
testing
.
T
)
{
func
TestTaintAndToleration
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
pod
*
api
.
Pod
pod
*
api
.
Pod
nodes
[]
api
.
Node
nodes
[]
*
api
.
Node
expectedList
schedulerapi
.
HostPriorityList
expectedList
schedulerapi
.
HostPriorityList
test
string
test
string
}{
}{
...
@@ -70,7 +70,7 @@ func TestTaintAndToleration(t *testing.T) {
...
@@ -70,7 +70,7 @@ func TestTaintAndToleration(t *testing.T) {
Value
:
"bar"
,
Value
:
"bar"
,
Effect
:
api
.
TaintEffectPreferNoSchedule
,
Effect
:
api
.
TaintEffectPreferNoSchedule
,
}}),
}}),
nodes
:
[]
api
.
Node
{
nodes
:
[]
*
api
.
Node
{
nodeWithTaints
(
"nodeA"
,
[]
api
.
Taint
{{
nodeWithTaints
(
"nodeA"
,
[]
api
.
Taint
{{
Key
:
"foo"
,
Key
:
"foo"
,
Value
:
"bar"
,
Value
:
"bar"
,
...
@@ -103,7 +103,7 @@ func TestTaintAndToleration(t *testing.T) {
...
@@ -103,7 +103,7 @@ func TestTaintAndToleration(t *testing.T) {
Effect
:
api
.
TaintEffectPreferNoSchedule
,
Effect
:
api
.
TaintEffectPreferNoSchedule
,
},
},
}),
}),
nodes
:
[]
api
.
Node
{
nodes
:
[]
*
api
.
Node
{
nodeWithTaints
(
"nodeA"
,
[]
api
.
Taint
{}),
nodeWithTaints
(
"nodeA"
,
[]
api
.
Taint
{}),
nodeWithTaints
(
"nodeB"
,
[]
api
.
Taint
{
nodeWithTaints
(
"nodeB"
,
[]
api
.
Taint
{
{
{
...
@@ -139,7 +139,7 @@ func TestTaintAndToleration(t *testing.T) {
...
@@ -139,7 +139,7 @@ func TestTaintAndToleration(t *testing.T) {
Value
:
"bar"
,
Value
:
"bar"
,
Effect
:
api
.
TaintEffectPreferNoSchedule
,
Effect
:
api
.
TaintEffectPreferNoSchedule
,
}}),
}}),
nodes
:
[]
api
.
Node
{
nodes
:
[]
*
api
.
Node
{
nodeWithTaints
(
"nodeA"
,
[]
api
.
Taint
{}),
nodeWithTaints
(
"nodeA"
,
[]
api
.
Taint
{}),
nodeWithTaints
(
"nodeB"
,
[]
api
.
Taint
{
nodeWithTaints
(
"nodeB"
,
[]
api
.
Taint
{
{
{
...
@@ -182,7 +182,7 @@ func TestTaintAndToleration(t *testing.T) {
...
@@ -182,7 +182,7 @@ func TestTaintAndToleration(t *testing.T) {
Effect
:
api
.
TaintEffectNoSchedule
,
Effect
:
api
.
TaintEffectNoSchedule
,
},
},
}),
}),
nodes
:
[]
api
.
Node
{
nodes
:
[]
*
api
.
Node
{
nodeWithTaints
(
"nodeA"
,
[]
api
.
Taint
{}),
nodeWithTaints
(
"nodeA"
,
[]
api
.
Taint
{}),
nodeWithTaints
(
"nodeB"
,
[]
api
.
Taint
{
nodeWithTaints
(
"nodeB"
,
[]
api
.
Taint
{
{
{
...
@@ -215,7 +215,7 @@ func TestTaintAndToleration(t *testing.T) {
...
@@ -215,7 +215,7 @@ func TestTaintAndToleration(t *testing.T) {
list
,
err
:=
ComputeTaintTolerationPriority
(
list
,
err
:=
ComputeTaintTolerationPriority
(
test
.
pod
,
test
.
pod
,
nodeNameToInfo
,
nodeNameToInfo
,
algorithm
.
FakeNodeLister
(
api
.
NodeList
{
Items
:
test
.
nodes
}
))
algorithm
.
FakeNodeLister
(
test
.
nodes
))
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"%s, unexpected error: %v"
,
test
.
test
,
err
)
t
.
Errorf
(
"%s, unexpected error: %v"
,
test
.
test
,
err
)
}
}
...
...
plugin/pkg/scheduler/algorithm/scheduler_interface.go
View file @
d14fe0f2
...
@@ -27,12 +27,12 @@ import (
...
@@ -27,12 +27,12 @@ import (
type
SchedulerExtender
interface
{
type
SchedulerExtender
interface
{
// Filter based on extender-implemented predicate functions. The filtered list is
// Filter based on extender-implemented predicate functions. The filtered list is
// expected to be a subset of the supplied list.
// expected to be a subset of the supplied list.
Filter
(
pod
*
api
.
Pod
,
nodes
*
api
.
NodeList
)
(
filteredNodes
*
api
.
NodeList
,
err
error
)
Filter
(
pod
*
api
.
Pod
,
nodes
[]
*
api
.
Node
)
(
filteredNodes
[]
*
api
.
Node
,
err
error
)
// Prioritize based on extender-implemented priority functions. The returned scores & weight
// Prioritize based on extender-implemented priority functions. The returned scores & weight
// are used to compute the weighted score for an extender. The weighted scores are added to
// are used to compute the weighted score for an extender. The weighted scores are added to
// the scores computed by Kubernetes scheduler. The total scores are used to do the host selection.
// the scores computed by Kubernetes scheduler. The total scores are used to do the host selection.
Prioritize
(
pod
*
api
.
Pod
,
nodes
*
api
.
NodeList
)
(
hostPriorities
*
schedulerapi
.
HostPriorityList
,
weight
int
,
err
error
)
Prioritize
(
pod
*
api
.
Pod
,
nodes
[]
*
api
.
Node
)
(
hostPriorities
*
schedulerapi
.
HostPriorityList
,
weight
int
,
err
error
)
}
}
// ScheduleAlgorithm is an interface implemented by things that know how to schedule pods
// ScheduleAlgorithm is an interface implemented by things that know how to schedule pods
...
...
plugin/pkg/scheduler/extender.go
View file @
d14fe0f2
...
@@ -93,16 +93,20 @@ func NewHTTPExtender(config *schedulerapi.ExtenderConfig, apiVersion string) (al
...
@@ -93,16 +93,20 @@ func NewHTTPExtender(config *schedulerapi.ExtenderConfig, apiVersion string) (al
// Filter based on extender implemented predicate functions. The filtered list is
// Filter based on extender implemented predicate functions. The filtered list is
// expected to be a subset of the supplied list.
// expected to be a subset of the supplied list.
func
(
h
*
HTTPExtender
)
Filter
(
pod
*
api
.
Pod
,
nodes
*
api
.
NodeList
)
(
*
api
.
NodeList
,
error
)
{
func
(
h
*
HTTPExtender
)
Filter
(
pod
*
api
.
Pod
,
nodes
[]
*
api
.
Node
)
([]
*
api
.
Node
,
error
)
{
var
result
schedulerapi
.
ExtenderFilterResult
var
result
schedulerapi
.
ExtenderFilterResult
if
h
.
filterVerb
==
""
{
if
h
.
filterVerb
==
""
{
return
nodes
,
nil
return
nodes
,
nil
}
}
nodeItems
:=
make
([]
api
.
Node
,
0
,
len
(
nodes
))
for
_
,
node
:=
range
nodes
{
nodeItems
=
append
(
nodeItems
,
*
node
)
}
args
:=
schedulerapi
.
ExtenderArgs
{
args
:=
schedulerapi
.
ExtenderArgs
{
Pod
:
*
pod
,
Pod
:
*
pod
,
Nodes
:
*
nodes
,
Nodes
:
api
.
NodeList
{
Items
:
nodeItems
}
,
}
}
if
err
:=
h
.
send
(
h
.
filterVerb
,
&
args
,
&
result
);
err
!=
nil
{
if
err
:=
h
.
send
(
h
.
filterVerb
,
&
args
,
&
result
);
err
!=
nil
{
...
@@ -111,26 +115,34 @@ func (h *HTTPExtender) Filter(pod *api.Pod, nodes *api.NodeList) (*api.NodeList,
...
@@ -111,26 +115,34 @@ func (h *HTTPExtender) Filter(pod *api.Pod, nodes *api.NodeList) (*api.NodeList,
if
result
.
Error
!=
""
{
if
result
.
Error
!=
""
{
return
nil
,
fmt
.
Errorf
(
result
.
Error
)
return
nil
,
fmt
.
Errorf
(
result
.
Error
)
}
}
return
&
result
.
Nodes
,
nil
nodeResult
:=
make
([]
*
api
.
Node
,
0
,
len
(
result
.
Nodes
.
Items
))
for
i
:=
range
result
.
Nodes
.
Items
{
nodeResult
=
append
(
nodeResult
,
&
result
.
Nodes
.
Items
[
i
])
}
return
nodeResult
,
nil
}
}
// Prioritize based on extender implemented priority functions. Weight*priority is added
// Prioritize based on extender implemented priority functions. Weight*priority is added
// up for each such priority function. The returned score is added to the score computed
// up for each such priority function. The returned score is added to the score computed
// by Kubernetes scheduler. The total score is used to do the host selection.
// by Kubernetes scheduler. The total score is used to do the host selection.
func
(
h
*
HTTPExtender
)
Prioritize
(
pod
*
api
.
Pod
,
nodes
*
api
.
NodeList
)
(
*
schedulerapi
.
HostPriorityList
,
int
,
error
)
{
func
(
h
*
HTTPExtender
)
Prioritize
(
pod
*
api
.
Pod
,
nodes
[]
*
api
.
Node
)
(
*
schedulerapi
.
HostPriorityList
,
int
,
error
)
{
var
result
schedulerapi
.
HostPriorityList
var
result
schedulerapi
.
HostPriorityList
if
h
.
prioritizeVerb
==
""
{
if
h
.
prioritizeVerb
==
""
{
result
:=
schedulerapi
.
HostPriorityList
{}
result
:=
schedulerapi
.
HostPriorityList
{}
for
_
,
node
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
{
result
=
append
(
result
,
schedulerapi
.
HostPriority
{
Host
:
node
.
Name
,
Score
:
0
})
result
=
append
(
result
,
schedulerapi
.
HostPriority
{
Host
:
node
.
Name
,
Score
:
0
})
}
}
return
&
result
,
0
,
nil
return
&
result
,
0
,
nil
}
}
nodeItems
:=
make
([]
api
.
Node
,
0
,
len
(
nodes
))
for
_
,
node
:=
range
nodes
{
nodeItems
=
append
(
nodeItems
,
*
node
)
}
args
:=
schedulerapi
.
ExtenderArgs
{
args
:=
schedulerapi
.
ExtenderArgs
{
Pod
:
*
pod
,
Pod
:
*
pod
,
Nodes
:
*
nodes
,
Nodes
:
api
.
NodeList
{
Items
:
nodeItems
}
,
}
}
if
err
:=
h
.
send
(
h
.
prioritizeVerb
,
&
args
,
&
result
);
err
!=
nil
{
if
err
:=
h
.
send
(
h
.
prioritizeVerb
,
&
args
,
&
result
);
err
!=
nil
{
...
...
plugin/pkg/scheduler/extender_test.go
View file @
d14fe0f2
...
@@ -28,7 +28,7 @@ import (
...
@@ -28,7 +28,7 @@ import (
)
)
type
fitPredicate
func
(
pod
*
api
.
Pod
,
node
*
api
.
Node
)
(
bool
,
error
)
type
fitPredicate
func
(
pod
*
api
.
Pod
,
node
*
api
.
Node
)
(
bool
,
error
)
type
priorityFunc
func
(
pod
*
api
.
Pod
,
nodes
*
api
.
NodeList
)
(
*
schedulerapi
.
HostPriorityList
,
error
)
type
priorityFunc
func
(
pod
*
api
.
Pod
,
nodes
[]
*
api
.
Node
)
(
*
schedulerapi
.
HostPriorityList
,
error
)
type
priorityConfig
struct
{
type
priorityConfig
struct
{
function
priorityFunc
function
priorityFunc
...
@@ -61,13 +61,13 @@ func machine2PredicateExtender(pod *api.Pod, node *api.Node) (bool, error) {
...
@@ -61,13 +61,13 @@ func machine2PredicateExtender(pod *api.Pod, node *api.Node) (bool, error) {
return
false
,
nil
return
false
,
nil
}
}
func
errorPrioritizerExtender
(
pod
*
api
.
Pod
,
nodes
*
api
.
NodeList
)
(
*
schedulerapi
.
HostPriorityList
,
error
)
{
func
errorPrioritizerExtender
(
pod
*
api
.
Pod
,
nodes
[]
*
api
.
Node
)
(
*
schedulerapi
.
HostPriorityList
,
error
)
{
return
&
schedulerapi
.
HostPriorityList
{},
fmt
.
Errorf
(
"Some error"
)
return
&
schedulerapi
.
HostPriorityList
{},
fmt
.
Errorf
(
"Some error"
)
}
}
func
machine1PrioritizerExtender
(
pod
*
api
.
Pod
,
nodes
*
api
.
NodeList
)
(
*
schedulerapi
.
HostPriorityList
,
error
)
{
func
machine1PrioritizerExtender
(
pod
*
api
.
Pod
,
nodes
[]
*
api
.
Node
)
(
*
schedulerapi
.
HostPriorityList
,
error
)
{
result
:=
schedulerapi
.
HostPriorityList
{}
result
:=
schedulerapi
.
HostPriorityList
{}
for
_
,
node
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
{
score
:=
1
score
:=
1
if
node
.
Name
==
"machine1"
{
if
node
.
Name
==
"machine1"
{
score
=
10
score
=
10
...
@@ -77,9 +77,9 @@ func machine1PrioritizerExtender(pod *api.Pod, nodes *api.NodeList) (*schedulera
...
@@ -77,9 +77,9 @@ func machine1PrioritizerExtender(pod *api.Pod, nodes *api.NodeList) (*schedulera
return
&
result
,
nil
return
&
result
,
nil
}
}
func
machine2PrioritizerExtender
(
pod
*
api
.
Pod
,
nodes
*
api
.
NodeList
)
(
*
schedulerapi
.
HostPriorityList
,
error
)
{
func
machine2PrioritizerExtender
(
pod
*
api
.
Pod
,
nodes
[]
*
api
.
Node
)
(
*
schedulerapi
.
HostPriorityList
,
error
)
{
result
:=
schedulerapi
.
HostPriorityList
{}
result
:=
schedulerapi
.
HostPriorityList
{}
for
_
,
node
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
{
score
:=
1
score
:=
1
if
node
.
Name
==
"machine2"
{
if
node
.
Name
==
"machine2"
{
score
=
10
score
=
10
...
@@ -96,7 +96,7 @@ func machine2Prioritizer(_ *api.Pod, nodeNameToInfo map[string]*schedulercache.N
...
@@ -96,7 +96,7 @@ func machine2Prioritizer(_ *api.Pod, nodeNameToInfo map[string]*schedulercache.N
}
}
result
:=
[]
schedulerapi
.
HostPriority
{}
result
:=
[]
schedulerapi
.
HostPriority
{}
for
_
,
node
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
{
score
:=
1
score
:=
1
if
node
.
Name
==
"machine2"
{
if
node
.
Name
==
"machine2"
{
score
=
10
score
=
10
...
@@ -112,14 +112,14 @@ type FakeExtender struct {
...
@@ -112,14 +112,14 @@ type FakeExtender struct {
weight
int
weight
int
}
}
func
(
f
*
FakeExtender
)
Filter
(
pod
*
api
.
Pod
,
nodes
*
api
.
NodeList
)
(
*
api
.
NodeList
,
error
)
{
func
(
f
*
FakeExtender
)
Filter
(
pod
*
api
.
Pod
,
nodes
[]
*
api
.
Node
)
([]
*
api
.
Node
,
error
)
{
filtered
:=
[]
api
.
Node
{}
filtered
:=
[]
*
api
.
Node
{}
for
_
,
node
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
{
fits
:=
true
fits
:=
true
for
_
,
predicate
:=
range
f
.
predicates
{
for
_
,
predicate
:=
range
f
.
predicates
{
fit
,
err
:=
predicate
(
pod
,
&
node
)
fit
,
err
:=
predicate
(
pod
,
node
)
if
err
!=
nil
{
if
err
!=
nil
{
return
&
api
.
NodeList
{},
err
return
[]
*
api
.
Node
{},
err
}
}
if
!
fit
{
if
!
fit
{
fits
=
false
fits
=
false
...
@@ -130,10 +130,10 @@ func (f *FakeExtender) Filter(pod *api.Pod, nodes *api.NodeList) (*api.NodeList,
...
@@ -130,10 +130,10 @@ func (f *FakeExtender) Filter(pod *api.Pod, nodes *api.NodeList) (*api.NodeList,
filtered
=
append
(
filtered
,
node
)
filtered
=
append
(
filtered
,
node
)
}
}
}
}
return
&
api
.
NodeList
{
Items
:
filtered
}
,
nil
return
filtered
,
nil
}
}
func
(
f
*
FakeExtender
)
Prioritize
(
pod
*
api
.
Pod
,
nodes
*
api
.
NodeList
)
(
*
schedulerapi
.
HostPriorityList
,
int
,
error
)
{
func
(
f
*
FakeExtender
)
Prioritize
(
pod
*
api
.
Pod
,
nodes
[]
*
api
.
Node
)
(
*
schedulerapi
.
HostPriorityList
,
int
,
error
)
{
result
:=
schedulerapi
.
HostPriorityList
{}
result
:=
schedulerapi
.
HostPriorityList
{}
combinedScores
:=
map
[
string
]
int
{}
combinedScores
:=
map
[
string
]
int
{}
for
_
,
prioritizer
:=
range
f
.
prioritizers
{
for
_
,
prioritizer
:=
range
f
.
prioritizers
{
...
...
plugin/pkg/scheduler/generic_scheduler.go
View file @
d14fe0f2
...
@@ -82,7 +82,7 @@ func (g *genericScheduler) Schedule(pod *api.Pod, nodeLister algorithm.NodeListe
...
@@ -82,7 +82,7 @@ func (g *genericScheduler) Schedule(pod *api.Pod, nodeLister algorithm.NodeListe
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
if
len
(
nodes
.
Items
)
==
0
{
if
len
(
nodes
)
==
0
{
return
""
,
ErrNoNodesAvailable
return
""
,
ErrNoNodesAvailable
}
}
...
@@ -98,7 +98,7 @@ func (g *genericScheduler) Schedule(pod *api.Pod, nodeLister algorithm.NodeListe
...
@@ -98,7 +98,7 @@ func (g *genericScheduler) Schedule(pod *api.Pod, nodeLister algorithm.NodeListe
return
""
,
err
return
""
,
err
}
}
if
len
(
filteredNodes
.
Items
)
==
0
{
if
len
(
filteredNodes
)
==
0
{
return
""
,
&
FitError
{
return
""
,
&
FitError
{
Pod
:
pod
,
Pod
:
pod
,
FailedPredicates
:
failedPredicateMap
,
FailedPredicates
:
failedPredicateMap
,
...
@@ -136,19 +136,19 @@ func (g *genericScheduler) selectHost(priorityList schedulerapi.HostPriorityList
...
@@ -136,19 +136,19 @@ func (g *genericScheduler) selectHost(priorityList schedulerapi.HostPriorityList
// Filters the nodes to find the ones that fit based on the given predicate functions
// Filters the nodes to find the ones that fit based on the given predicate functions
// Each node is passed through the predicate functions to determine if it is a fit
// Each node is passed through the predicate functions to determine if it is a fit
func
findNodesThatFit
(
pod
*
api
.
Pod
,
nodeNameToInfo
map
[
string
]
*
schedulercache
.
NodeInfo
,
predicateFuncs
map
[
string
]
algorithm
.
FitPredicate
,
nodes
api
.
NodeList
,
extenders
[]
algorithm
.
SchedulerExtender
)
(
api
.
NodeList
,
FailedPredicateMap
,
error
)
{
func
findNodesThatFit
(
pod
*
api
.
Pod
,
nodeNameToInfo
map
[
string
]
*
schedulercache
.
NodeInfo
,
predicateFuncs
map
[
string
]
algorithm
.
FitPredicate
,
nodes
[]
*
api
.
Node
,
extenders
[]
algorithm
.
SchedulerExtender
)
([]
*
api
.
Node
,
FailedPredicateMap
,
error
)
{
// Create filtered list with enough space to avoid growing it.
// Create filtered list with enough space to avoid growing it.
filtered
:=
make
([]
api
.
Node
,
0
,
len
(
nodes
.
Item
s
))
filtered
:=
make
([]
*
api
.
Node
,
0
,
len
(
node
s
))
failedPredicateMap
:=
FailedPredicateMap
{}
failedPredicateMap
:=
FailedPredicateMap
{}
if
len
(
predicateFuncs
)
==
0
{
if
len
(
predicateFuncs
)
==
0
{
filtered
=
nodes
.
Items
filtered
=
nodes
}
else
{
}
else
{
predicateResultLock
:=
sync
.
Mutex
{}
predicateResultLock
:=
sync
.
Mutex
{}
errs
:=
[]
error
{}
errs
:=
[]
error
{}
meta
:=
predicates
.
PredicateMetadata
(
pod
)
meta
:=
predicates
.
PredicateMetadata
(
pod
)
checkNode
:=
func
(
i
int
)
{
checkNode
:=
func
(
i
int
)
{
nodeName
:=
nodes
.
Items
[
i
]
.
Name
nodeName
:=
nodes
[
i
]
.
Name
fits
,
failedPredicate
,
err
:=
podFitsOnNode
(
pod
,
meta
,
nodeNameToInfo
[
nodeName
],
predicateFuncs
)
fits
,
failedPredicate
,
err
:=
podFitsOnNode
(
pod
,
meta
,
nodeNameToInfo
[
nodeName
],
predicateFuncs
)
predicateResultLock
.
Lock
()
predicateResultLock
.
Lock
()
...
@@ -158,30 +158,30 @@ func findNodesThatFit(pod *api.Pod, nodeNameToInfo map[string]*schedulercache.No
...
@@ -158,30 +158,30 @@ func findNodesThatFit(pod *api.Pod, nodeNameToInfo map[string]*schedulercache.No
return
return
}
}
if
fits
{
if
fits
{
filtered
=
append
(
filtered
,
nodes
.
Items
[
i
])
filtered
=
append
(
filtered
,
nodes
[
i
])
}
else
{
}
else
{
failedPredicateMap
[
nodeName
]
=
failedPredicate
failedPredicateMap
[
nodeName
]
=
failedPredicate
}
}
}
}
workqueue
.
Parallelize
(
16
,
len
(
nodes
.
Items
),
checkNode
)
workqueue
.
Parallelize
(
16
,
len
(
nodes
),
checkNode
)
if
len
(
errs
)
>
0
{
if
len
(
errs
)
>
0
{
return
api
.
NodeList
{},
FailedPredicateMap
{},
errors
.
NewAggregate
(
errs
)
return
[]
*
api
.
Node
{},
FailedPredicateMap
{},
errors
.
NewAggregate
(
errs
)
}
}
}
}
if
len
(
filtered
)
>
0
&&
len
(
extenders
)
!=
0
{
if
len
(
filtered
)
>
0
&&
len
(
extenders
)
!=
0
{
for
_
,
extender
:=
range
extenders
{
for
_
,
extender
:=
range
extenders
{
filteredList
,
err
:=
extender
.
Filter
(
pod
,
&
api
.
NodeList
{
Items
:
filtered
}
)
filteredList
,
err
:=
extender
.
Filter
(
pod
,
filtered
)
if
err
!=
nil
{
if
err
!=
nil
{
return
api
.
NodeList
{},
FailedPredicateMap
{},
err
return
[]
*
api
.
Node
{},
FailedPredicateMap
{},
err
}
}
filtered
=
filteredList
.
Items
filtered
=
filteredList
if
len
(
filtered
)
==
0
{
if
len
(
filtered
)
==
0
{
break
break
}
}
}
}
}
}
return
api
.
NodeList
{
Items
:
filtered
}
,
failedPredicateMap
,
nil
return
filtered
,
failedPredicateMap
,
nil
}
}
// Checks whether node with a given name and NodeInfo satisfies all predicateFuncs.
// Checks whether node with a given name and NodeInfo satisfies all predicateFuncs.
...
@@ -288,7 +288,7 @@ func PrioritizeNodes(
...
@@ -288,7 +288,7 @@ func PrioritizeNodes(
wg
.
Add
(
1
)
wg
.
Add
(
1
)
go
func
(
ext
algorithm
.
SchedulerExtender
)
{
go
func
(
ext
algorithm
.
SchedulerExtender
)
{
defer
wg
.
Done
()
defer
wg
.
Done
()
prioritizedList
,
weight
,
err
:=
ext
.
Prioritize
(
pod
,
&
nodes
)
prioritizedList
,
weight
,
err
:=
ext
.
Prioritize
(
pod
,
nodes
)
if
err
!=
nil
{
if
err
!=
nil
{
// Prioritization errors from extender can be ignored, let k8s/other extenders determine the priorities
// Prioritization errors from extender can be ignored, let k8s/other extenders determine the priorities
return
return
...
@@ -320,8 +320,8 @@ func EqualPriority(_ *api.Pod, nodeNameToInfo map[string]*schedulercache.NodeInf
...
@@ -320,8 +320,8 @@ func EqualPriority(_ *api.Pod, nodeNameToInfo map[string]*schedulercache.NodeInf
return
[]
schedulerapi
.
HostPriority
{},
err
return
[]
schedulerapi
.
HostPriority
{},
err
}
}
result
:=
[]
schedulerapi
.
HostPriority
{}
result
:=
make
(
schedulerapi
.
HostPriorityList
,
len
(
nodes
))
for
_
,
node
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
{
result
=
append
(
result
,
schedulerapi
.
HostPriority
{
result
=
append
(
result
,
schedulerapi
.
HostPriority
{
Host
:
node
.
Name
,
Host
:
node
.
Name
,
Score
:
1
,
Score
:
1
,
...
...
plugin/pkg/scheduler/generic_scheduler_test.go
View file @
d14fe0f2
...
@@ -66,7 +66,7 @@ func numericPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulercache.Nod
...
@@ -66,7 +66,7 @@ func numericPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulercache.Nod
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to list nodes: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"failed to list nodes: %v"
,
err
)
}
}
for
_
,
node
:=
range
nodes
.
Items
{
for
_
,
node
:=
range
nodes
{
score
,
err
:=
strconv
.
Atoi
(
node
.
Name
)
score
,
err
:=
strconv
.
Atoi
(
node
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -102,12 +102,10 @@ func reverseNumericPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulerca
...
@@ -102,12 +102,10 @@ func reverseNumericPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulerca
return
reverseResult
,
nil
return
reverseResult
,
nil
}
}
func
makeNodeList
(
nodeNames
[]
string
)
api
.
NodeList
{
func
makeNodeList
(
nodeNames
[]
string
)
[]
*
api
.
Node
{
result
:=
api
.
NodeList
{
result
:=
make
([]
*
api
.
Node
,
0
,
len
(
nodeNames
))
Items
:
make
([]
api
.
Node
,
len
(
nodeNames
)),
for
_
,
nodeName
:=
range
nodeNames
{
}
result
=
append
(
result
,
&
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
nodeName
}})
for
ix
:=
range
nodeNames
{
result
.
Items
[
ix
]
.
Name
=
nodeNames
[
ix
]
}
}
return
result
return
result
}
}
...
...
plugin/pkg/scheduler/scheduler_test.go
View file @
d14fe0f2
...
@@ -125,7 +125,7 @@ func TestScheduler(t *testing.T) {
...
@@ -125,7 +125,7 @@ func TestScheduler(t *testing.T) {
},
},
},
},
NodeLister
:
algorithm
.
FakeNodeLister
(
NodeLister
:
algorithm
.
FakeNodeLister
(
api
.
NodeList
{
Items
:
[]
api
.
Node
{{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine1"
}
}}},
[]
*
api
.
Node
{{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine1"
}}},
),
),
Algorithm
:
item
.
algo
,
Algorithm
:
item
.
algo
,
Binder
:
fakeBinder
{
func
(
b
*
api
.
Binding
)
error
{
Binder
:
fakeBinder
{
func
(
b
*
api
.
Binding
)
error
{
...
@@ -292,7 +292,7 @@ func setupTestSchedulerWithOnePod(t *testing.T, queuedPodStore *clientcache.FIFO
...
@@ -292,7 +292,7 @@ func setupTestSchedulerWithOnePod(t *testing.T, queuedPodStore *clientcache.FIFO
cfg
:=
&
Config
{
cfg
:=
&
Config
{
SchedulerCache
:
scache
,
SchedulerCache
:
scache
,
NodeLister
:
algorithm
.
FakeNodeLister
(
NodeLister
:
algorithm
.
FakeNodeLister
(
api
.
NodeList
{
Items
:
[]
api
.
Node
{{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine1"
}
}}},
[]
*
api
.
Node
{{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine1"
}}},
),
),
Algorithm
:
algo
,
Algorithm
:
algo
,
Binder
:
fakeBinder
{
func
(
b
*
api
.
Binding
)
error
{
Binder
:
fakeBinder
{
func
(
b
*
api
.
Binding
)
error
{
...
...
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