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
1ab5fc43
Commit
1ab5fc43
authored
May 24, 2016
by
Filip Grzadkowski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #26069 from fgrzadkowski/unschedulable_pod
Refactor scheduler to expose predicates to cluster autoscaler
parents
31610387
55a1c826
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
37 deletions
+62
-37
factory.go
plugin/pkg/scheduler/factory/factory.go
+62
-37
No files found.
plugin/pkg/scheduler/factory/factory.go
View file @
1ab5fc43
...
...
@@ -305,6 +305,64 @@ func (f *ConfigFactory) CreateFromKeys(predicateKeys, priorityKeys sets.String,
return
nil
,
fmt
.
Errorf
(
"invalid hardPodAffinitySymmetricWeight: %d, must be in the range 0-100"
,
f
.
HardPodAffinitySymmetricWeight
)
}
predicateFuncs
,
err
:=
f
.
GetPredicates
(
predicateKeys
)
if
err
!=
nil
{
return
nil
,
err
}
priorityConfigs
,
err
:=
f
.
GetPriorityFunctionConfigs
(
priorityKeys
)
if
err
!=
nil
{
return
nil
,
err
}
f
.
Run
()
r
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
algo
:=
scheduler
.
NewGenericScheduler
(
f
.
schedulerCache
,
predicateFuncs
,
priorityConfigs
,
extenders
,
r
)
podBackoff
:=
podBackoff
{
perPodBackoff
:
map
[
types
.
NamespacedName
]
*
backoffEntry
{},
clock
:
realClock
{},
defaultDuration
:
1
*
time
.
Second
,
maxDuration
:
60
*
time
.
Second
,
}
return
&
scheduler
.
Config
{
SchedulerCache
:
f
.
schedulerCache
,
// The scheduler only needs to consider schedulable nodes.
NodeLister
:
f
.
NodeLister
.
NodeCondition
(
getNodeConditionPredicate
()),
Algorithm
:
algo
,
Binder
:
&
binder
{
f
.
Client
},
PodConditionUpdater
:
&
podConditionUpdater
{
f
.
Client
},
NextPod
:
func
()
*
api
.
Pod
{
return
f
.
getNextPod
()
},
Error
:
f
.
makeDefaultErrorFunc
(
&
podBackoff
,
f
.
PodQueue
),
StopEverything
:
f
.
StopEverything
,
},
nil
}
func
(
f
*
ConfigFactory
)
GetPriorityFunctionConfigs
(
priorityKeys
sets
.
String
)
([]
algorithm
.
PriorityConfig
,
error
)
{
pluginArgs
,
err
:=
f
.
getPluginArgs
()
if
err
!=
nil
{
return
nil
,
err
}
return
getPriorityFunctionConfigs
(
priorityKeys
,
*
pluginArgs
)
}
func
(
f
*
ConfigFactory
)
GetPredicates
(
predicateKeys
sets
.
String
)
(
map
[
string
]
algorithm
.
FitPredicate
,
error
)
{
pluginArgs
,
err
:=
f
.
getPluginArgs
()
if
err
!=
nil
{
return
nil
,
err
}
return
getFitPredicateFunctions
(
predicateKeys
,
*
pluginArgs
)
}
func
(
f
*
ConfigFactory
)
getPluginArgs
()
(
*
PluginFactoryArgs
,
error
)
{
failureDomainArgs
:=
strings
.
Split
(
f
.
FailureDomains
,
","
)
for
_
,
failureDomain
:=
range
failureDomainArgs
{
if
errs
:=
utilvalidation
.
IsQualifiedName
(
failureDomain
);
len
(
errs
)
!=
0
{
...
...
@@ -312,7 +370,7 @@ func (f *ConfigFactory) CreateFromKeys(predicateKeys, priorityKeys sets.String,
}
}
pluginArgs
:=
PluginFactoryArgs
{
return
&
PluginFactoryArgs
{
PodLister
:
f
.
PodLister
,
ServiceLister
:
f
.
ServiceLister
,
ControllerLister
:
f
.
ControllerLister
,
...
...
@@ -324,17 +382,10 @@ func (f *ConfigFactory) CreateFromKeys(predicateKeys, priorityKeys sets.String,
PVCInfo
:
f
.
PVCLister
,
HardPodAffinitySymmetricWeight
:
f
.
HardPodAffinitySymmetricWeight
,
FailureDomains
:
sets
.
NewString
(
failureDomainArgs
...
)
.
List
(),
}
predicateFuncs
,
err
:=
getFitPredicateFunctions
(
predicateKeys
,
pluginArgs
)
if
err
!=
nil
{
return
nil
,
err
}
priorityConfigs
,
err
:=
getPriorityFunctionConfigs
(
priorityKeys
,
pluginArgs
)
if
err
!=
nil
{
return
nil
,
err
}
},
nil
}
func
(
f
*
ConfigFactory
)
Run
()
{
// Watch and queue pods that need scheduling.
cache
.
NewReflector
(
f
.
createUnassignedNonTerminatedPodLW
(),
&
api
.
Pod
{},
f
.
PodQueue
,
0
)
.
RunUntil
(
f
.
StopEverything
)
...
...
@@ -363,32 +414,6 @@ func (f *ConfigFactory) CreateFromKeys(predicateKeys, priorityKeys sets.String,
// created by the same services or ReplicationControllers/ReplicaSets, so that it can spread them correctly.
// Cache this locally.
cache
.
NewReflector
(
f
.
createReplicaSetLW
(),
&
extensions
.
ReplicaSet
{},
f
.
ReplicaSetLister
.
Store
,
0
)
.
RunUntil
(
f
.
StopEverything
)
r
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
algo
:=
scheduler
.
NewGenericScheduler
(
f
.
schedulerCache
,
predicateFuncs
,
priorityConfigs
,
extenders
,
r
)
podBackoff
:=
podBackoff
{
perPodBackoff
:
map
[
types
.
NamespacedName
]
*
backoffEntry
{},
clock
:
realClock
{},
defaultDuration
:
1
*
time
.
Second
,
maxDuration
:
60
*
time
.
Second
,
}
return
&
scheduler
.
Config
{
SchedulerCache
:
f
.
schedulerCache
,
// The scheduler only needs to consider schedulable nodes.
NodeLister
:
f
.
NodeLister
.
NodeCondition
(
getNodeConditionPredicate
()),
Algorithm
:
algo
,
Binder
:
&
binder
{
f
.
Client
},
PodConditionUpdater
:
&
podConditionUpdater
{
f
.
Client
},
NextPod
:
func
()
*
api
.
Pod
{
return
f
.
getNextPod
()
},
Error
:
f
.
makeDefaultErrorFunc
(
&
podBackoff
,
f
.
PodQueue
),
StopEverything
:
f
.
StopEverything
,
},
nil
}
func
(
f
*
ConfigFactory
)
getNextPod
()
*
api
.
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