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
afaef937
Unverified
Commit
afaef937
authored
Dec 14, 2018
by
Kubernetes Prow Robot
Committed by
GitHub
Dec 14, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #72061 from misterikkit/WhatIsAnAlgorithm
Move `ScheduleAlgorithm` to the core package.
parents
85470369
8e253613
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
20 deletions
+21
-20
scheduler_interface.go
pkg/scheduler/algorithm/scheduler_interface.go
+0
-17
generic_scheduler.go
pkg/scheduler/core/generic_scheduler.go
+19
-1
factory.go
pkg/scheduler/factory/factory.go
+1
-1
scheduler_test.go
pkg/scheduler/scheduler_test.go
+1
-1
No files found.
pkg/scheduler/algorithm/scheduler_interface.go
View file @
afaef937
...
...
@@ -72,20 +72,3 @@ type SchedulerExtender interface {
// is unavailable. This gives scheduler ability to fail fast and tolerate non-critical extenders as well.
IsIgnorable
()
bool
}
// ScheduleAlgorithm is an interface implemented by things that know how to schedule pods
// onto machines.
type
ScheduleAlgorithm
interface
{
Schedule
(
*
v1
.
Pod
,
NodeLister
)
(
selectedMachine
string
,
err
error
)
// Preempt receives scheduling errors for a pod and tries to create room for
// the pod by preempting lower priority pods if possible.
// It returns the node where preemption happened, a list of preempted pods, a
// list of pods whose nominated node name should be removed, and error if any.
Preempt
(
*
v1
.
Pod
,
NodeLister
,
error
)
(
selectedNode
*
v1
.
Node
,
preemptedPods
[]
*
v1
.
Pod
,
cleanupNominatedPods
[]
*
v1
.
Pod
,
err
error
)
// Predicates() returns a pointer to a map of predicate functions. This is
// exposed for testing.
Predicates
()
map
[
string
]
FitPredicate
// Prioritizers returns a slice of priority config. This is exposed for
// testing.
Prioritizers
()
[]
PriorityConfig
}
pkg/scheduler/core/generic_scheduler.go
View file @
afaef937
...
...
@@ -96,6 +96,24 @@ func (f *FitError) Error() string {
return
reasonMsg
}
// ScheduleAlgorithm is an interface implemented by things that know how to schedule pods
// onto machines.
// TODO: Rename this type.
type
ScheduleAlgorithm
interface
{
Schedule
(
*
v1
.
Pod
,
algorithm
.
NodeLister
)
(
selectedMachine
string
,
err
error
)
// Preempt receives scheduling errors for a pod and tries to create room for
// the pod by preempting lower priority pods if possible.
// It returns the node where preemption happened, a list of preempted pods, a
// list of pods whose nominated node name should be removed, and error if any.
Preempt
(
*
v1
.
Pod
,
algorithm
.
NodeLister
,
error
)
(
selectedNode
*
v1
.
Node
,
preemptedPods
[]
*
v1
.
Pod
,
cleanupNominatedPods
[]
*
v1
.
Pod
,
err
error
)
// Predicates() returns a pointer to a map of predicate functions. This is
// exposed for testing.
Predicates
()
map
[
string
]
algorithm
.
FitPredicate
// Prioritizers returns a slice of priority config. This is exposed for
// testing.
Prioritizers
()
[]
algorithm
.
PriorityConfig
}
type
genericScheduler
struct
{
cache
schedulerinternalcache
.
Cache
equivalenceCache
*
equivalence
.
Cache
...
...
@@ -1164,7 +1182,7 @@ func NewGenericScheduler(
alwaysCheckAllPredicates
bool
,
disablePreemption
bool
,
percentageOfNodesToScore
int32
,
)
algorithm
.
ScheduleAlgorithm
{
)
ScheduleAlgorithm
{
return
&
genericScheduler
{
cache
:
cache
,
equivalenceCache
:
eCache
,
...
...
pkg/scheduler/factory/factory.go
View file @
afaef937
...
...
@@ -103,7 +103,7 @@ type Config struct {
// successfully binding a pod
Ecache
*
equivalence
.
Cache
NodeLister
algorithm
.
NodeLister
Algorithm
algorithm
.
ScheduleAlgorithm
Algorithm
core
.
ScheduleAlgorithm
GetBinder
func
(
pod
*
v1
.
Pod
)
Binder
// PodConditionUpdater is used only in case of scheduling errors. If we succeed
// with scheduling, PodScheduled condition will be updated in apiserver in /bind
...
...
pkg/scheduler/scheduler_test.go
View file @
afaef937
...
...
@@ -211,7 +211,7 @@ func TestScheduler(t *testing.T) {
name
string
injectBindError
error
sendPod
*
v1
.
Pod
algo
algorithm
.
ScheduleAlgorithm
algo
core
.
ScheduleAlgorithm
expectErrorPod
*
v1
.
Pod
expectForgetPod
*
v1
.
Pod
expectAssumedPod
*
v1
.
Pod
...
...
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