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
d60bccc6
Commit
d60bccc6
authored
May 07, 2019
by
draveness
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: implement "queue-sort" extension point for scheduling framework
parent
08afeb85
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
48 additions
and
8 deletions
+48
-8
extender_test.go
pkg/scheduler/core/extender_test.go
+1
-1
generic_scheduler_test.go
pkg/scheduler/core/generic_scheduler_test.go
+3
-3
factory.go
pkg/scheduler/factory/factory.go
+1
-1
factory_test.go
pkg/scheduler/factory/factory_test.go
+1
-1
framework.go
pkg/scheduler/framework/v1alpha1/framework.go
+15
-0
interface.go
pkg/scheduler/framework/v1alpha1/interface.go
+22
-0
BUILD
pkg/scheduler/internal/queue/BUILD
+3
-0
scheduling_queue.go
pkg/scheduler/internal/queue/scheduling_queue.go
+0
-0
scheduling_queue_test.go
pkg/scheduler/internal/queue/scheduling_queue_test.go
+0
-0
scheduler_test.go
pkg/scheduler/scheduler_test.go
+2
-2
No files found.
pkg/scheduler/core/extender_test.go
View file @
d60bccc6
...
@@ -536,7 +536,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
...
@@ -536,7 +536,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
for
_
,
name
:=
range
test
.
nodes
{
for
_
,
name
:=
range
test
.
nodes
{
cache
.
AddNode
(
createNode
(
name
))
cache
.
AddNode
(
createNode
(
name
))
}
}
queue
:=
internalqueue
.
NewSchedulingQueue
(
nil
)
queue
:=
internalqueue
.
NewSchedulingQueue
(
nil
,
nil
)
scheduler
:=
NewGenericScheduler
(
scheduler
:=
NewGenericScheduler
(
cache
,
cache
,
queue
,
queue
,
...
...
pkg/scheduler/core/generic_scheduler_test.go
View file @
d60bccc6
...
@@ -452,7 +452,7 @@ func TestGenericScheduler(t *testing.T) {
...
@@ -452,7 +452,7 @@ func TestGenericScheduler(t *testing.T) {
scheduler
:=
NewGenericScheduler
(
scheduler
:=
NewGenericScheduler
(
cache
,
cache
,
internalqueue
.
NewSchedulingQueue
(
nil
),
internalqueue
.
NewSchedulingQueue
(
nil
,
nil
),
test
.
predicates
,
test
.
predicates
,
algorithmpredicates
.
EmptyPredicateMetadataProducer
,
algorithmpredicates
.
EmptyPredicateMetadataProducer
,
test
.
prioritizers
,
test
.
prioritizers
,
...
@@ -488,7 +488,7 @@ func makeScheduler(predicates map[string]algorithmpredicates.FitPredicate, nodes
...
@@ -488,7 +488,7 @@ func makeScheduler(predicates map[string]algorithmpredicates.FitPredicate, nodes
s
:=
NewGenericScheduler
(
s
:=
NewGenericScheduler
(
cache
,
cache
,
internalqueue
.
NewSchedulingQueue
(
nil
),
internalqueue
.
NewSchedulingQueue
(
nil
,
nil
),
predicates
,
predicates
,
algorithmpredicates
.
EmptyPredicateMetadataProducer
,
algorithmpredicates
.
EmptyPredicateMetadataProducer
,
prioritizers
,
prioritizers
,
...
@@ -1491,7 +1491,7 @@ func TestPreempt(t *testing.T) {
...
@@ -1491,7 +1491,7 @@ func TestPreempt(t *testing.T) {
}
}
scheduler
:=
NewGenericScheduler
(
scheduler
:=
NewGenericScheduler
(
cache
,
cache
,
internalqueue
.
NewSchedulingQueue
(
nil
),
internalqueue
.
NewSchedulingQueue
(
nil
,
nil
),
map
[
string
]
algorithmpredicates
.
FitPredicate
{
"matches"
:
algorithmpredicates
.
PodFitsResources
},
map
[
string
]
algorithmpredicates
.
FitPredicate
{
"matches"
:
algorithmpredicates
.
PodFitsResources
},
algorithmpredicates
.
EmptyPredicateMetadataProducer
,
algorithmpredicates
.
EmptyPredicateMetadataProducer
,
[]
priorities
.
PriorityConfig
{{
Function
:
numericPriority
,
Weight
:
1
}},
[]
priorities
.
PriorityConfig
{{
Function
:
numericPriority
,
Weight
:
1
}},
...
...
pkg/scheduler/factory/factory.go
View file @
d60bccc6
...
@@ -262,7 +262,7 @@ func NewConfigFactory(args *ConfigFactoryArgs) Configurator {
...
@@ -262,7 +262,7 @@ func NewConfigFactory(args *ConfigFactoryArgs) Configurator {
c
:=
&
configFactory
{
c
:=
&
configFactory
{
client
:
args
.
Client
,
client
:
args
.
Client
,
podLister
:
schedulerCache
,
podLister
:
schedulerCache
,
podQueue
:
internalqueue
.
NewSchedulingQueue
(
stopEverything
),
podQueue
:
internalqueue
.
NewSchedulingQueue
(
stopEverything
,
framework
),
nodeLister
:
args
.
NodeInformer
.
Lister
(),
nodeLister
:
args
.
NodeInformer
.
Lister
(),
pVLister
:
args
.
PvInformer
.
Lister
(),
pVLister
:
args
.
PvInformer
.
Lister
(),
pVCLister
:
args
.
PvcInformer
.
Lister
(),
pVCLister
:
args
.
PvcInformer
.
Lister
(),
...
...
pkg/scheduler/factory/factory_test.go
View file @
d60bccc6
...
@@ -256,7 +256,7 @@ func TestDefaultErrorFunc(t *testing.T) {
...
@@ -256,7 +256,7 @@ func TestDefaultErrorFunc(t *testing.T) {
defer
close
(
stopCh
)
defer
close
(
stopCh
)
timestamp
:=
time
.
Now
()
timestamp
:=
time
.
Now
()
queue
:=
internalqueue
.
NewPriorityQueueWithClock
(
nil
,
clock
.
NewFakeClock
(
timestamp
))
queue
:=
internalqueue
.
NewPriorityQueueWithClock
(
nil
,
clock
.
NewFakeClock
(
timestamp
)
,
nil
)
schedulerCache
:=
internalcache
.
New
(
30
*
time
.
Second
,
stopCh
)
schedulerCache
:=
internalcache
.
New
(
30
*
time
.
Second
,
stopCh
)
errFunc
:=
MakeDefaultErrorFunc
(
client
,
queue
,
schedulerCache
,
stopCh
)
errFunc
:=
MakeDefaultErrorFunc
(
client
,
queue
,
schedulerCache
,
stopCh
)
...
...
pkg/scheduler/framework/v1alpha1/framework.go
View file @
d60bccc6
...
@@ -34,6 +34,7 @@ type framework struct {
...
@@ -34,6 +34,7 @@ type framework struct {
nodeInfoSnapshot
*
cache
.
NodeInfoSnapshot
nodeInfoSnapshot
*
cache
.
NodeInfoSnapshot
waitingPods
*
waitingPodsMap
waitingPods
*
waitingPodsMap
plugins
map
[
string
]
Plugin
// a map of initialized plugins. Plugin name:plugin instance.
plugins
map
[
string
]
Plugin
// a map of initialized plugins. Plugin name:plugin instance.
queueSortPlugins
[]
QueueSortPlugin
reservePlugins
[]
ReservePlugin
reservePlugins
[]
ReservePlugin
prebindPlugins
[]
PrebindPlugin
prebindPlugins
[]
PrebindPlugin
unreservePlugins
[]
UnreservePlugin
unreservePlugins
[]
UnreservePlugin
...
@@ -69,6 +70,10 @@ func NewFramework(r Registry, _ *runtime.Unknown) (Framework, error) {
...
@@ -69,6 +70,10 @@ func NewFramework(r Registry, _ *runtime.Unknown) (Framework, error) {
// TODO: For now, we assume any plugins that implements an extension
// TODO: For now, we assume any plugins that implements an extension
// point wants to be called at that extension point. We should change this
// point wants to be called at that extension point. We should change this
// later and add these plugins based on the configuration.
// later and add these plugins based on the configuration.
if
qsp
,
ok
:=
p
.
(
QueueSortPlugin
);
ok
{
f
.
queueSortPlugins
=
append
(
f
.
queueSortPlugins
,
qsp
)
}
if
rp
,
ok
:=
p
.
(
ReservePlugin
);
ok
{
if
rp
,
ok
:=
p
.
(
ReservePlugin
);
ok
{
f
.
reservePlugins
=
append
(
f
.
reservePlugins
,
rp
)
f
.
reservePlugins
=
append
(
f
.
reservePlugins
,
rp
)
}
}
...
@@ -85,6 +90,16 @@ func NewFramework(r Registry, _ *runtime.Unknown) (Framework, error) {
...
@@ -85,6 +90,16 @@ func NewFramework(r Registry, _ *runtime.Unknown) (Framework, error) {
return
f
,
nil
return
f
,
nil
}
}
// QueueSortFunc returns the function to sort pods in scheduling queue
func
(
f
*
framework
)
QueueSortFunc
()
LessFunc
{
if
len
(
f
.
queueSortPlugins
)
==
0
{
return
nil
}
// Only one QueueSort plugin can be enabled.
return
f
.
queueSortPlugins
[
0
]
.
Less
}
// RunPrebindPlugins runs the set of configured prebind plugins. It returns a
// RunPrebindPlugins runs the set of configured prebind plugins. It returns a
// failure (bool) if any of the plugins returns an error. It also returns an
// failure (bool) if any of the plugins returns an error. It also returns an
// error containing the rejection message or the error occurred in the plugin.
// error containing the rejection message or the error occurred in the plugin.
...
...
pkg/scheduler/framework/v1alpha1/interface.go
View file @
d60bccc6
...
@@ -107,6 +107,25 @@ type Plugin interface {
...
@@ -107,6 +107,25 @@ type Plugin interface {
Name
()
string
Name
()
string
}
}
// PodInfo is minimum cell in the scheduling queue.
type
PodInfo
struct
{
Pod
*
v1
.
Pod
// The time pod added to the scheduling queue.
Timestamp
time
.
Time
}
// LessFunc is the function to sort pod info
type
LessFunc
func
(
podInfo1
,
podInfo2
*
PodInfo
)
bool
// QueueSortPlugin is an interface that must be implemented by "QueueSort" plugins.
// These plugins are used to sort pods in the scheduling queue. Only one queue sort
// plugin may be enabled at a time.
type
QueueSortPlugin
interface
{
Plugin
// Less are used to sort pods in the scheduling queue.
Less
(
*
PodInfo
,
*
PodInfo
)
bool
}
// ReservePlugin is an interface for Reserve plugins. These plugins are called
// ReservePlugin is an interface for Reserve plugins. These plugins are called
// at the reservation point. These are meant to update the state of the plugin.
// at the reservation point. These are meant to update the state of the plugin.
// This concept used to be called 'assume' in the original scheduler.
// This concept used to be called 'assume' in the original scheduler.
...
@@ -157,6 +176,9 @@ type PermitPlugin interface {
...
@@ -157,6 +176,9 @@ type PermitPlugin interface {
// Configured plugins are called at specified points in a scheduling context.
// Configured plugins are called at specified points in a scheduling context.
type
Framework
interface
{
type
Framework
interface
{
FrameworkHandle
FrameworkHandle
// QueueSortFunc returns the function to sort pods in scheduling queue
QueueSortFunc
()
LessFunc
// RunPrebindPlugins runs the set of configured prebind plugins. It returns
// RunPrebindPlugins runs the set of configured prebind plugins. It returns
// *Status and its code is set to non-success if any of the plugins returns
// *Status and its code is set to non-success if any of the plugins returns
// anything but Success. If the Status code is "Unschedulable", it is
// anything but Success. If the Status code is "Unschedulable", it is
...
...
pkg/scheduler/internal/queue/BUILD
View file @
d60bccc6
...
@@ -11,6 +11,7 @@ go_library(
...
@@ -11,6 +11,7 @@ go_library(
deps = [
deps = [
"//pkg/scheduler/algorithm/predicates:go_default_library",
"//pkg/scheduler/algorithm/predicates:go_default_library",
"//pkg/scheduler/algorithm/priorities/util:go_default_library",
"//pkg/scheduler/algorithm/priorities/util:go_default_library",
"//pkg/scheduler/framework/v1alpha1:go_default_library",
"//pkg/scheduler/metrics:go_default_library",
"//pkg/scheduler/metrics:go_default_library",
"//pkg/scheduler/util:go_default_library",
"//pkg/scheduler/util:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
...
@@ -31,6 +32,8 @@ go_test(
...
@@ -31,6 +32,8 @@ go_test(
embed = [":go_default_library"],
embed = [":go_default_library"],
deps = [
deps = [
"//pkg/api/v1/pod:go_default_library",
"//pkg/api/v1/pod:go_default_library",
"//pkg/scheduler/framework/v1alpha1:go_default_library",
"//pkg/scheduler/internal/cache:go_default_library",
"//pkg/scheduler/metrics:go_default_library",
"//pkg/scheduler/metrics:go_default_library",
"//pkg/scheduler/util:go_default_library",
"//pkg/scheduler/util:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
...
...
pkg/scheduler/internal/queue/scheduling_queue.go
View file @
d60bccc6
This diff is collapsed.
Click to expand it.
pkg/scheduler/internal/queue/scheduling_queue_test.go
View file @
d60bccc6
This diff is collapsed.
Click to expand it.
pkg/scheduler/scheduler_test.go
View file @
d60bccc6
...
@@ -641,7 +641,7 @@ func setupTestScheduler(queuedPodStore *clientcache.FIFO, scache internalcache.C
...
@@ -641,7 +641,7 @@ func setupTestScheduler(queuedPodStore *clientcache.FIFO, scache internalcache.C
framework
,
_
:=
framework
.
NewFramework
(
EmptyPluginRegistry
,
nil
)
framework
,
_
:=
framework
.
NewFramework
(
EmptyPluginRegistry
,
nil
)
algo
:=
core
.
NewGenericScheduler
(
algo
:=
core
.
NewGenericScheduler
(
scache
,
scache
,
internalqueue
.
NewSchedulingQueue
(
nil
),
internalqueue
.
NewSchedulingQueue
(
nil
,
nil
),
predicateMap
,
predicateMap
,
predicates
.
EmptyPredicateMetadataProducer
,
predicates
.
EmptyPredicateMetadataProducer
,
[]
priorities
.
PriorityConfig
{},
[]
priorities
.
PriorityConfig
{},
...
@@ -694,7 +694,7 @@ func setupTestSchedulerLongBindingWithRetry(queuedPodStore *clientcache.FIFO, sc
...
@@ -694,7 +694,7 @@ func setupTestSchedulerLongBindingWithRetry(queuedPodStore *clientcache.FIFO, sc
framework
,
_
:=
framework
.
NewFramework
(
EmptyPluginRegistry
,
nil
)
framework
,
_
:=
framework
.
NewFramework
(
EmptyPluginRegistry
,
nil
)
algo
:=
core
.
NewGenericScheduler
(
algo
:=
core
.
NewGenericScheduler
(
scache
,
scache
,
internalqueue
.
NewSchedulingQueue
(
nil
),
internalqueue
.
NewSchedulingQueue
(
nil
,
nil
),
predicateMap
,
predicateMap
,
predicates
.
EmptyPredicateMetadataProducer
,
predicates
.
EmptyPredicateMetadataProducer
,
[]
priorities
.
PriorityConfig
{},
[]
priorities
.
PriorityConfig
{},
...
...
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