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
79601acb
Commit
79601acb
authored
Jan 23, 2018
by
Bobby (Babak) Salamat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add better event handling for deleted Pods
parent
7652c252
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
24 deletions
+58
-24
factory.go
pkg/scheduler/factory/factory.go
+58
-24
No files found.
pkg/scheduler/factory/factory.go
View file @
79601acb
...
@@ -189,6 +189,13 @@ func NewConfigFactory(
...
@@ -189,6 +189,13 @@ func NewConfigFactory(
switch
t
:=
obj
.
(
type
)
{
switch
t
:=
obj
.
(
type
)
{
case
*
v1
.
Pod
:
case
*
v1
.
Pod
:
return
assignedNonTerminatedPod
(
t
)
return
assignedNonTerminatedPod
(
t
)
case
cache
.
DeletedFinalStateUnknown
:
if
pod
,
ok
:=
t
.
Obj
.
(
*
v1
.
Pod
);
ok
{
return
assignedNonTerminatedPod
(
pod
)
}
else
{
runtime
.
HandleError
(
fmt
.
Errorf
(
"unable to convert object %T to *v1.Pod in %T"
,
obj
,
c
))
return
false
}
default
:
default
:
runtime
.
HandleError
(
fmt
.
Errorf
(
"unable to handle object in %T: %T"
,
c
,
obj
))
runtime
.
HandleError
(
fmt
.
Errorf
(
"unable to handle object in %T: %T"
,
c
,
obj
))
return
false
return
false
...
@@ -208,36 +215,22 @@ func NewConfigFactory(
...
@@ -208,36 +215,22 @@ func NewConfigFactory(
switch
t
:=
obj
.
(
type
)
{
switch
t
:=
obj
.
(
type
)
{
case
*
v1
.
Pod
:
case
*
v1
.
Pod
:
return
unassignedNonTerminatedPod
(
t
)
return
unassignedNonTerminatedPod
(
t
)
case
cache
.
DeletedFinalStateUnknown
:
if
pod
,
ok
:=
t
.
Obj
.
(
*
v1
.
Pod
);
ok
{
return
unassignedNonTerminatedPod
(
pod
)
}
else
{
runtime
.
HandleError
(
fmt
.
Errorf
(
"unable to convert object %T to *v1.Pod in %T"
,
obj
,
c
))
return
false
}
default
:
default
:
runtime
.
HandleError
(
fmt
.
Errorf
(
"unable to handle object in %T: %T"
,
c
,
obj
))
runtime
.
HandleError
(
fmt
.
Errorf
(
"unable to handle object in %T: %T"
,
c
,
obj
))
return
false
return
false
}
}
},
},
Handler
:
cache
.
ResourceEventHandlerFuncs
{
Handler
:
cache
.
ResourceEventHandlerFuncs
{
AddFunc
:
func
(
obj
interface
{})
{
AddFunc
:
c
.
addPodToSchedulingQueue
,
if
err
:=
c
.
podQueue
.
Add
(
obj
.
(
*
v1
.
Pod
));
err
!=
nil
{
UpdateFunc
:
c
.
updatePodInSchedulingQueue
,
runtime
.
HandleError
(
fmt
.
Errorf
(
"unable to queue %T: %v"
,
obj
,
err
))
DeleteFunc
:
c
.
deletePodFromSchedulingQueue
,
}
},
UpdateFunc
:
func
(
oldObj
,
newObj
interface
{})
{
pod
:=
newObj
.
(
*
v1
.
Pod
)
if
c
.
skipPodUpdate
(
pod
)
{
return
}
if
err
:=
c
.
podQueue
.
Update
(
pod
);
err
!=
nil
{
runtime
.
HandleError
(
fmt
.
Errorf
(
"unable to update %T: %v"
,
newObj
,
err
))
}
},
DeleteFunc
:
func
(
obj
interface
{})
{
pod
:=
obj
.
(
*
v1
.
Pod
)
if
err
:=
c
.
podQueue
.
Delete
(
pod
);
err
!=
nil
{
runtime
.
HandleError
(
fmt
.
Errorf
(
"unable to dequeue %T: %v"
,
obj
,
err
))
}
if
c
.
volumeBinder
!=
nil
{
// Volume binder only wants to keep unassigned pods
c
.
volumeBinder
.
DeletePodBindings
(
pod
)
}
},
},
},
},
},
)
)
...
@@ -591,6 +584,47 @@ func (c *configFactory) updatePodInCache(oldObj, newObj interface{}) {
...
@@ -591,6 +584,47 @@ func (c *configFactory) updatePodInCache(oldObj, newObj interface{}) {
c
.
podQueue
.
AssignedPodUpdated
(
newPod
)
c
.
podQueue
.
AssignedPodUpdated
(
newPod
)
}
}
func
(
c
*
configFactory
)
addPodToSchedulingQueue
(
obj
interface
{})
{
if
err
:=
c
.
podQueue
.
Add
(
obj
.
(
*
v1
.
Pod
));
err
!=
nil
{
runtime
.
HandleError
(
fmt
.
Errorf
(
"unable to queue %T: %v"
,
obj
,
err
))
}
}
func
(
c
*
configFactory
)
updatePodInSchedulingQueue
(
oldObj
,
newObj
interface
{})
{
pod
:=
newObj
.
(
*
v1
.
Pod
)
if
c
.
skipPodUpdate
(
pod
)
{
return
}
if
err
:=
c
.
podQueue
.
Update
(
pod
);
err
!=
nil
{
runtime
.
HandleError
(
fmt
.
Errorf
(
"unable to update %T: %v"
,
newObj
,
err
))
}
}
func
(
c
*
configFactory
)
deletePodFromSchedulingQueue
(
obj
interface
{})
{
var
pod
*
v1
.
Pod
switch
t
:=
obj
.
(
type
)
{
case
*
v1
.
Pod
:
pod
=
obj
.
(
*
v1
.
Pod
)
case
cache
.
DeletedFinalStateUnknown
:
var
ok
bool
pod
,
ok
=
t
.
Obj
.
(
*
v1
.
Pod
)
if
!
ok
{
runtime
.
HandleError
(
fmt
.
Errorf
(
"unable to convert object %T to *v1.Pod in %T"
,
obj
,
c
))
return
}
default
:
runtime
.
HandleError
(
fmt
.
Errorf
(
"unable to handle object in %T: %T"
,
c
,
obj
))
return
}
if
err
:=
c
.
podQueue
.
Delete
(
pod
);
err
!=
nil
{
runtime
.
HandleError
(
fmt
.
Errorf
(
"unable to dequeue %T: %v"
,
obj
,
err
))
}
if
c
.
volumeBinder
!=
nil
{
// Volume binder only wants to keep unassigned pods
c
.
volumeBinder
.
DeletePodBindings
(
pod
)
}
}
func
(
c
*
configFactory
)
invalidateCachedPredicatesOnUpdatePod
(
newPod
*
v1
.
Pod
,
oldPod
*
v1
.
Pod
)
{
func
(
c
*
configFactory
)
invalidateCachedPredicatesOnUpdatePod
(
newPod
*
v1
.
Pod
,
oldPod
*
v1
.
Pod
)
{
if
c
.
enableEquivalenceClassCache
{
if
c
.
enableEquivalenceClassCache
{
// if the pod does not have bound node, updating equivalence cache is meaningless;
// if the pod does not have bound node, updating equivalence cache is meaningless;
...
...
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