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
5442f9d4
Unverified
Commit
5442f9d4
authored
Oct 09, 2018
by
k8s-ci-robot
Committed by
GitHub
Oct 09, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #69592 from bsalamat/filterfunc
Remove pod status.phase check from pod event handlers
parents
40338626
5f2555e3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
24 deletions
+7
-24
factory.go
pkg/scheduler/factory/factory.go
+7
-24
No files found.
pkg/scheduler/factory/factory.go
View file @
5442f9d4
...
@@ -202,10 +202,10 @@ func NewConfigFactory(args *ConfigFactoryArgs) scheduler.Configurator {
...
@@ -202,10 +202,10 @@ func NewConfigFactory(args *ConfigFactoryArgs) scheduler.Configurator {
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
assigned
NonTerminated
Pod
(
t
)
return
assignedPod
(
t
)
case
cache
.
DeletedFinalStateUnknown
:
case
cache
.
DeletedFinalStateUnknown
:
if
pod
,
ok
:=
t
.
Obj
.
(
*
v1
.
Pod
);
ok
{
if
pod
,
ok
:=
t
.
Obj
.
(
*
v1
.
Pod
);
ok
{
return
assigned
NonTerminated
Pod
(
pod
)
return
assignedPod
(
pod
)
}
}
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
...
@@ -227,10 +227,10 @@ func NewConfigFactory(args *ConfigFactoryArgs) scheduler.Configurator {
...
@@ -227,10 +227,10 @@ func NewConfigFactory(args *ConfigFactoryArgs) scheduler.Configurator {
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
unassignedNonTerminat
edPod
(
t
)
&&
responsibleForPod
(
t
,
args
.
SchedulerName
)
return
!
assign
edPod
(
t
)
&&
responsibleForPod
(
t
,
args
.
SchedulerName
)
case
cache
.
DeletedFinalStateUnknown
:
case
cache
.
DeletedFinalStateUnknown
:
if
pod
,
ok
:=
t
.
Obj
.
(
*
v1
.
Pod
);
ok
{
if
pod
,
ok
:=
t
.
Obj
.
(
*
v1
.
Pod
);
ok
{
return
unassignedNonTerminat
edPod
(
pod
)
&&
responsibleForPod
(
pod
,
args
.
SchedulerName
)
return
!
assign
edPod
(
pod
)
&&
responsibleForPod
(
pod
,
args
.
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
...
@@ -1240,26 +1240,9 @@ func (c *configFactory) getNextPod() *v1.Pod {
...
@@ -1240,26 +1240,9 @@ func (c *configFactory) getNextPod() *v1.Pod {
return
nil
return
nil
}
}
// unassignedNonTerminatedPod selects pods that are unassigned and non-terminal.
// assignedPod selects pods that are assigned (scheduled and running).
func
unassignedNonTerminatedPod
(
pod
*
v1
.
Pod
)
bool
{
func
assignedPod
(
pod
*
v1
.
Pod
)
bool
{
if
len
(
pod
.
Spec
.
NodeName
)
!=
0
{
return
len
(
pod
.
Spec
.
NodeName
)
!=
0
return
false
}
if
pod
.
Status
.
Phase
==
v1
.
PodSucceeded
||
pod
.
Status
.
Phase
==
v1
.
PodFailed
{
return
false
}
return
true
}
// assignedNonTerminatedPod selects pods that are assigned and non-terminal (scheduled and running).
func
assignedNonTerminatedPod
(
pod
*
v1
.
Pod
)
bool
{
if
len
(
pod
.
Spec
.
NodeName
)
==
0
{
return
false
}
if
pod
.
Status
.
Phase
==
v1
.
PodSucceeded
||
pod
.
Status
.
Phase
==
v1
.
PodFailed
{
return
false
}
return
true
}
}
// responsibleForPod returns true if the pod has asked to be scheduled by the given scheduler.
// responsibleForPod returns true if the pod has asked to be scheduled by the given scheduler.
...
...
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