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
a073dfdb
Commit
a073dfdb
authored
Apr 23, 2018
by
Bobby (Babak) Salamat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix scheduler Pod informers to receive events when pods are scheduled by other schedulers.
parent
719a56fa
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
7 deletions
+11
-7
server.go
cmd/kube-scheduler/app/server.go
+1
-1
factory.go
pkg/scheduler/factory/factory.go
+9
-5
util.go
test/integration/scheduler/util.go
+1
-1
No files found.
cmd/kube-scheduler/app/server.go
View file @
a073dfdb
...
@@ -476,7 +476,7 @@ func NewSchedulerServer(config *componentconfig.KubeSchedulerConfiguration, mast
...
@@ -476,7 +476,7 @@ func NewSchedulerServer(config *componentconfig.KubeSchedulerConfiguration, mast
SchedulerName
:
config
.
SchedulerName
,
SchedulerName
:
config
.
SchedulerName
,
Client
:
client
,
Client
:
client
,
InformerFactory
:
informers
.
NewSharedInformerFactory
(
client
,
0
),
InformerFactory
:
informers
.
NewSharedInformerFactory
(
client
,
0
),
PodInformer
:
factory
.
NewPodInformer
(
client
,
0
,
config
.
SchedulerName
),
PodInformer
:
factory
.
NewPodInformer
(
client
,
0
),
AlgorithmSource
:
config
.
AlgorithmSource
,
AlgorithmSource
:
config
.
AlgorithmSource
,
HardPodAffinitySymmetricWeight
:
config
.
HardPodAffinitySymmetricWeight
,
HardPodAffinitySymmetricWeight
:
config
.
HardPodAffinitySymmetricWeight
,
EventClient
:
eventClient
,
EventClient
:
eventClient
,
...
...
pkg/scheduler/factory/factory.go
View file @
a073dfdb
...
@@ -218,10 +218,10 @@ func NewConfigFactory(
...
@@ -218,10 +218,10 @@ func NewConfigFactory(
FilterFunc
:
func
(
obj
interface
{})
bool
{
FilterFunc
:
func
(
obj
interface
{})
bool
{
switch
t
:=
obj
.
(
type
)
{
switch
t
:=
obj
.
(
type
)
{
case
*
v1
.
Pod
:
case
*
v1
.
Pod
:
return
unassignedNonTerminatedPod
(
t
)
return
unassignedNonTerminatedPod
(
t
)
&&
responsibleForPod
(
t
,
schedulerName
)
case
cache
.
DeletedFinalStateUnknown
:
case
cache
.
DeletedFinalStateUnknown
:
if
pod
,
ok
:=
t
.
Obj
.
(
*
v1
.
Pod
);
ok
{
if
pod
,
ok
:=
t
.
Obj
.
(
*
v1
.
Pod
);
ok
{
return
unassignedNonTerminatedPod
(
pod
)
return
unassignedNonTerminatedPod
(
pod
)
&&
responsibleForPod
(
pod
,
schedulerName
)
}
}
runtime
.
HandleError
(
fmt
.
Errorf
(
"unable to convert object %T to *v1.Pod in %T"
,
obj
,
c
))
runtime
.
HandleError
(
fmt
.
Errorf
(
"unable to convert object %T to *v1.Pod in %T"
,
obj
,
c
))
return
false
return
false
...
@@ -1198,6 +1198,11 @@ func assignedNonTerminatedPod(pod *v1.Pod) bool {
...
@@ -1198,6 +1198,11 @@ func assignedNonTerminatedPod(pod *v1.Pod) bool {
return
true
return
true
}
}
// responsibleForPod returns true if the pod has asked to be scheduled by the given scheduler.
func
responsibleForPod
(
pod
*
v1
.
Pod
,
schedulerName
string
)
bool
{
return
schedulerName
==
pod
.
Spec
.
SchedulerName
}
// assignedPodLister filters the pods returned from a PodLister to
// assignedPodLister filters the pods returned from a PodLister to
// only include those that have a node name set.
// only include those that have a node name set.
type
assignedPodLister
struct
{
type
assignedPodLister
struct
{
...
@@ -1270,10 +1275,9 @@ func (i *podInformer) Lister() corelisters.PodLister {
...
@@ -1270,10 +1275,9 @@ func (i *podInformer) Lister() corelisters.PodLister {
}
}
// NewPodInformer creates a shared index informer that returns only non-terminal pods.
// NewPodInformer creates a shared index informer that returns only non-terminal pods.
func
NewPodInformer
(
client
clientset
.
Interface
,
resyncPeriod
time
.
Duration
,
schedulerName
string
)
coreinformers
.
PodInformer
{
func
NewPodInformer
(
client
clientset
.
Interface
,
resyncPeriod
time
.
Duration
)
coreinformers
.
PodInformer
{
selector
:=
fields
.
ParseSelectorOrDie
(
selector
:=
fields
.
ParseSelectorOrDie
(
"spec.schedulerName="
+
schedulerName
+
"status.phase!="
+
string
(
v1
.
PodSucceeded
)
+
",status.phase!="
+
string
(
v1
.
PodSucceeded
)
+
",status.phase!="
+
string
(
v1
.
PodFailed
))
",status.phase!="
+
string
(
v1
.
PodFailed
))
lw
:=
cache
.
NewListWatchFromClient
(
client
.
CoreV1
()
.
RESTClient
(),
string
(
v1
.
ResourcePods
),
metav1
.
NamespaceAll
,
selector
)
lw
:=
cache
.
NewListWatchFromClient
(
client
.
CoreV1
()
.
RESTClient
(),
string
(
v1
.
ResourcePods
),
metav1
.
NamespaceAll
,
selector
)
return
&
podInformer
{
return
&
podInformer
{
...
...
test/integration/scheduler/util.go
View file @
a073dfdb
...
@@ -164,7 +164,7 @@ func initTestSchedulerWithOptions(
...
@@ -164,7 +164,7 @@ func initTestSchedulerWithOptions(
// create independent pod informer if required
// create independent pod informer if required
if
setPodInformer
{
if
setPodInformer
{
podInformer
=
factory
.
NewPodInformer
(
context
.
clientSet
,
12
*
time
.
Hour
,
v1
.
DefaultSchedulerName
)
podInformer
=
factory
.
NewPodInformer
(
context
.
clientSet
,
12
*
time
.
Hour
)
}
else
{
}
else
{
podInformer
=
context
.
informerFactory
.
Core
()
.
V1
()
.
Pods
()
podInformer
=
context
.
informerFactory
.
Core
()
.
V1
()
.
Pods
()
}
}
...
...
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