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
f4f4e5cb
Commit
f4f4e5cb
authored
Dec 23, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #18817 from mqliang/schedulerSelector
Auto commit by PR queue bot
parents
05a12950
e58eae31
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
54 deletions
+8
-54
predicates.go
plugin/pkg/scheduler/algorithm/predicates/predicates.go
+0
-15
factory.go
plugin/pkg/scheduler/factory/factory.go
+8
-7
generic_scheduler_test.go
plugin/pkg/scheduler/generic_scheduler_test.go
+0
-32
No files found.
plugin/pkg/scheduler/algorithm/predicates/predicates.go
View file @
f4f4e5cb
...
@@ -427,20 +427,6 @@ func getUsedPorts(pods ...*api.Pod) map[int]bool {
...
@@ -427,20 +427,6 @@ func getUsedPorts(pods ...*api.Pod) map[int]bool {
return
ports
return
ports
}
}
func
filterNonRunningPods
(
pods
[]
*
api
.
Pod
)
[]
*
api
.
Pod
{
if
len
(
pods
)
==
0
{
return
pods
}
result
:=
[]
*
api
.
Pod
{}
for
_
,
pod
:=
range
pods
{
if
pod
.
Status
.
Phase
==
api
.
PodSucceeded
||
pod
.
Status
.
Phase
==
api
.
PodFailed
{
continue
}
result
=
append
(
result
,
pod
)
}
return
result
}
// MapPodsToMachines obtains a list of pods and pivots that list into a map where the keys are host names
// MapPodsToMachines obtains a list of pods and pivots that list into a map where the keys are host names
// and the values are the list of pods running on that host.
// and the values are the list of pods running on that host.
func
MapPodsToMachines
(
lister
algorithm
.
PodLister
)
(
map
[
string
][]
*
api
.
Pod
,
error
)
{
func
MapPodsToMachines
(
lister
algorithm
.
PodLister
)
(
map
[
string
][]
*
api
.
Pod
,
error
)
{
...
@@ -450,7 +436,6 @@ func MapPodsToMachines(lister algorithm.PodLister) (map[string][]*api.Pod, error
...
@@ -450,7 +436,6 @@ func MapPodsToMachines(lister algorithm.PodLister) (map[string][]*api.Pod, error
if
err
!=
nil
{
if
err
!=
nil
{
return
map
[
string
][]
*
api
.
Pod
{},
err
return
map
[
string
][]
*
api
.
Pod
{},
err
}
}
pods
=
filterNonRunningPods
(
pods
)
for
_
,
scheduledPod
:=
range
pods
{
for
_
,
scheduledPod
:=
range
pods
{
host
:=
scheduledPod
.
Spec
.
NodeName
host
:=
scheduledPod
.
Spec
.
NodeName
machineToPods
[
host
]
=
append
(
machineToPods
[
host
],
scheduledPod
)
machineToPods
[
host
]
=
append
(
machineToPods
[
host
],
scheduledPod
)
...
...
plugin/pkg/scheduler/factory/factory.go
View file @
f4f4e5cb
...
@@ -100,7 +100,7 @@ func NewConfigFactory(client *client.Client, rateLimiter util.RateLimiter, sched
...
@@ -100,7 +100,7 @@ func NewConfigFactory(client *client.Client, rateLimiter util.RateLimiter, sched
// ScheduledPodLister is something we provide to plug in functions that
// ScheduledPodLister is something we provide to plug in functions that
// they may need to call.
// they may need to call.
c
.
ScheduledPodLister
.
Store
,
c
.
scheduledPodPopulator
=
framework
.
NewInformer
(
c
.
ScheduledPodLister
.
Store
,
c
.
scheduledPodPopulator
=
framework
.
NewInformer
(
c
.
createAssignedPodLW
(),
c
.
createAssigned
NonTerminated
PodLW
(),
&
api
.
Pod
{},
&
api
.
Pod
{},
0
,
0
,
framework
.
ResourceEventHandlerFuncs
{
framework
.
ResourceEventHandlerFuncs
{
...
@@ -200,7 +200,7 @@ func (f *ConfigFactory) CreateFromKeys(predicateKeys, priorityKeys sets.String,
...
@@ -200,7 +200,7 @@ func (f *ConfigFactory) CreateFromKeys(predicateKeys, priorityKeys sets.String,
}
}
// Watch and queue pods that need scheduling.
// Watch and queue pods that need scheduling.
cache
.
NewReflector
(
f
.
createUnassignedPodLW
(),
&
api
.
Pod
{},
f
.
PodQueue
,
0
)
.
RunUntil
(
f
.
StopEverything
)
cache
.
NewReflector
(
f
.
createUnassigned
NonTerminated
PodLW
(),
&
api
.
Pod
{},
f
.
PodQueue
,
0
)
.
RunUntil
(
f
.
StopEverything
)
// Begin populating scheduled pods.
// Begin populating scheduled pods.
go
f
.
scheduledPodPopulator
.
Run
(
f
.
StopEverything
)
go
f
.
scheduledPodPopulator
.
Run
(
f
.
StopEverything
)
...
@@ -283,16 +283,17 @@ func getNodeConditionPredicate() cache.NodeConditionPredicate {
...
@@ -283,16 +283,17 @@ func getNodeConditionPredicate() cache.NodeConditionPredicate {
// Returns a cache.ListWatch that finds all pods that need to be
// Returns a cache.ListWatch that finds all pods that need to be
// scheduled.
// scheduled.
func
(
factory
*
ConfigFactory
)
createUnassignedPodLW
()
*
cache
.
ListWatch
{
func
(
factory
*
ConfigFactory
)
createUnassignedNonTerminatedPodLW
()
*
cache
.
ListWatch
{
return
cache
.
NewListWatchFromClient
(
factory
.
Client
,
"pods"
,
api
.
NamespaceAll
,
fields
.
Set
{
client
.
PodHost
:
""
}
.
AsSelector
())
selector
:=
fields
.
ParseSelectorOrDie
(
"spec.nodeName=="
+
""
+
",status.phase!="
+
string
(
api
.
PodSucceeded
)
+
",status.phase!="
+
string
(
api
.
PodFailed
))
return
cache
.
NewListWatchFromClient
(
factory
.
Client
,
"pods"
,
api
.
NamespaceAll
,
selector
)
}
}
// Returns a cache.ListWatch that finds all pods that are
// Returns a cache.ListWatch that finds all pods that are
// already scheduled.
// already scheduled.
// TODO: return a ListerWatcher interface instead?
// TODO: return a ListerWatcher interface instead?
func
(
factory
*
ConfigFactory
)
createAssignedPodLW
()
*
cache
.
ListWatch
{
func
(
factory
*
ConfigFactory
)
createAssigned
NonTerminated
PodLW
()
*
cache
.
ListWatch
{
return
cache
.
NewListWatchFromClient
(
factory
.
Client
,
"pods"
,
api
.
NamespaceAll
,
selector
:=
fields
.
ParseSelectorOrDie
(
"spec.nodeName!="
+
""
+
",status.phase!="
+
string
(
api
.
PodSucceeded
)
+
",status.phase!="
+
string
(
api
.
PodFailed
))
fields
.
ParseSelectorOrDie
(
client
.
PodHost
+
"!="
)
)
return
cache
.
NewListWatchFromClient
(
factory
.
Client
,
"pods"
,
api
.
NamespaceAll
,
selector
)
}
}
// createNodeLW returns a cache.ListWatch that gets all changes to nodes.
// createNodeLW returns a cache.ListWatch that gets all changes to nodes.
...
...
plugin/pkg/scheduler/generic_scheduler_test.go
View file @
f4f4e5cb
...
@@ -252,38 +252,6 @@ func TestGenericScheduler(t *testing.T) {
...
@@ -252,38 +252,6 @@ func TestGenericScheduler(t *testing.T) {
expectsErr
:
true
,
expectsErr
:
true
,
name
:
"test 8"
,
name
:
"test 8"
,
},
},
{
predicates
:
map
[
string
]
algorithm
.
FitPredicate
{
"nopods"
:
hasNoPodsPredicate
,
"matches"
:
matchesPredicate
,
},
pods
:
[]
*
api
.
Pod
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"2"
},
Spec
:
api
.
PodSpec
{
NodeName
:
"2"
,
},
Status
:
api
.
PodStatus
{
Phase
:
api
.
PodFailed
,
},
},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"3"
},
Spec
:
api
.
PodSpec
{
NodeName
:
"2"
,
},
Status
:
api
.
PodStatus
{
Phase
:
api
.
PodSucceeded
,
},
},
},
pod
:
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"2"
}},
prioritizers
:
[]
algorithm
.
PriorityConfig
{{
Function
:
numericPriority
,
Weight
:
1
}},
nodes
:
[]
string
{
"1"
,
"2"
},
expectedHost
:
"2"
,
name
:
"test 9"
,
},
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
...
...
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