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
d6dab28b
Commit
d6dab28b
authored
Aug 07, 2015
by
Jerzy Szczepkowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Move prioritizer function EqualPriority to package priorities"
parent
0bc3fab6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
25 deletions
+24
-25
priorities.go
plugin/pkg/scheduler/algorithm/priorities/priorities.go
+0
-18
defaults.go
plugin/pkg/scheduler/algorithmprovider/defaults/defaults.go
+2
-1
generic_scheduler.go
plugin/pkg/scheduler/generic_scheduler.go
+19
-2
generic_scheduler_test.go
plugin/pkg/scheduler/generic_scheduler_test.go
+3
-4
No files found.
plugin/pkg/scheduler/algorithm/priorities/priorities.go
View file @
d6dab28b
...
...
@@ -245,21 +245,3 @@ func fractionOfCapacity(requested, capacity int64) float64 {
}
return
float64
(
requested
)
/
float64
(
capacity
)
}
// EqualPriority is a prioritizer function that gives an equal score of one to all nodes
func
EqualPriority
(
_
*
api
.
Pod
,
podLister
algorithm
.
PodLister
,
minionLister
algorithm
.
MinionLister
)
(
algorithm
.
HostPriorityList
,
error
)
{
nodes
,
err
:=
minionLister
.
List
()
if
err
!=
nil
{
glog
.
Errorf
(
"failed to list nodes: %v"
,
err
)
return
[]
algorithm
.
HostPriority
{},
err
}
result
:=
[]
algorithm
.
HostPriority
{}
for
_
,
minion
:=
range
nodes
.
Items
{
result
=
append
(
result
,
algorithm
.
HostPriority
{
Host
:
minion
.
Name
,
Score
:
1
,
})
}
return
result
,
nil
}
plugin/pkg/scheduler/algorithmprovider/defaults/defaults.go
View file @
d6dab28b
...
...
@@ -19,6 +19,7 @@ package defaults
import
(
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/plugin/pkg/scheduler"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/predicates"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/priorities"
...
...
@@ -30,7 +31,7 @@ func init() {
// EqualPriority is a prioritizer function that gives an equal weight of one to all minions
// Register the priority function so that its available
// but do not include it as part of the default priorities
factory
.
RegisterPriorityFunction
(
"EqualPriority"
,
priorities
.
EqualPriority
,
1
)
factory
.
RegisterPriorityFunction
(
"EqualPriority"
,
scheduler
.
EqualPriority
,
1
)
}
func
defaultPredicates
()
util
.
StringSet
{
...
...
plugin/pkg/scheduler/generic_scheduler.go
View file @
d6dab28b
...
...
@@ -28,7 +28,6 @@ import (
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/predicates"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/priorities"
)
type
FailedPredicateMap
map
[
string
]
util
.
StringSet
...
...
@@ -149,7 +148,7 @@ func PrioritizeNodes(pod *api.Pod, podLister algorithm.PodLister, priorityConfig
// If no priority configs are provided, then the EqualPriority function is applied
// This is required to generate the priority list in the required format
if
len
(
priorityConfigs
)
==
0
{
return
priorities
.
EqualPriority
(
pod
,
podLister
,
minionLister
)
return
EqualPriority
(
pod
,
podLister
,
minionLister
)
}
combinedScores
:=
map
[
string
]
int
{}
...
...
@@ -187,6 +186,24 @@ func getBestHosts(list algorithm.HostPriorityList) []string {
return
result
}
// EqualPriority is a prioritizer function that gives an equal weight of one to all nodes
func
EqualPriority
(
_
*
api
.
Pod
,
podLister
algorithm
.
PodLister
,
minionLister
algorithm
.
MinionLister
)
(
algorithm
.
HostPriorityList
,
error
)
{
nodes
,
err
:=
minionLister
.
List
()
if
err
!=
nil
{
glog
.
Errorf
(
"failed to list nodes: %v"
,
err
)
return
[]
algorithm
.
HostPriority
{},
err
}
result
:=
[]
algorithm
.
HostPriority
{}
for
_
,
minion
:=
range
nodes
.
Items
{
result
=
append
(
result
,
algorithm
.
HostPriority
{
Host
:
minion
.
Name
,
Score
:
1
,
})
}
return
result
,
nil
}
func
NewGenericScheduler
(
predicates
map
[
string
]
algorithm
.
FitPredicate
,
prioritizers
[]
algorithm
.
PriorityConfig
,
pods
algorithm
.
PodLister
,
random
*
rand
.
Rand
)
algorithm
.
ScheduleAlgorithm
{
return
&
genericScheduler
{
predicates
:
predicates
,
...
...
plugin/pkg/scheduler/generic_scheduler_test.go
View file @
d6dab28b
...
...
@@ -26,7 +26,6 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/priorities"
)
func
falsePredicate
(
pod
*
api
.
Pod
,
existingPods
[]
*
api
.
Pod
,
node
string
)
(
bool
,
error
)
{
...
...
@@ -177,14 +176,14 @@ func TestGenericScheduler(t *testing.T) {
}{
{
predicates
:
map
[
string
]
algorithm
.
FitPredicate
{
"false"
:
falsePredicate
},
prioritizers
:
[]
algorithm
.
PriorityConfig
{{
Function
:
priorities
.
EqualPriority
,
Weight
:
1
}},
prioritizers
:
[]
algorithm
.
PriorityConfig
{{
Function
:
EqualPriority
,
Weight
:
1
}},
nodes
:
[]
string
{
"machine1"
,
"machine2"
},
expectsErr
:
true
,
name
:
"test 1"
,
},
{
predicates
:
map
[
string
]
algorithm
.
FitPredicate
{
"true"
:
truePredicate
},
prioritizers
:
[]
algorithm
.
PriorityConfig
{{
Function
:
priorities
.
EqualPriority
,
Weight
:
1
}},
prioritizers
:
[]
algorithm
.
PriorityConfig
{{
Function
:
EqualPriority
,
Weight
:
1
}},
nodes
:
[]
string
{
"machine1"
,
"machine2"
},
// Random choice between both, the rand seeded above with zero, chooses "machine1"
expectedHost
:
"machine1"
,
...
...
@@ -193,7 +192,7 @@ func TestGenericScheduler(t *testing.T) {
{
// Fits on a machine where the pod ID matches the machine name
predicates
:
map
[
string
]
algorithm
.
FitPredicate
{
"matches"
:
matchesPredicate
},
prioritizers
:
[]
algorithm
.
PriorityConfig
{{
Function
:
priorities
.
EqualPriority
,
Weight
:
1
}},
prioritizers
:
[]
algorithm
.
PriorityConfig
{{
Function
:
EqualPriority
,
Weight
:
1
}},
nodes
:
[]
string
{
"machine1"
,
"machine2"
},
pod
:
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"machine2"
}},
expectedHost
:
"machine2"
,
...
...
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