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
05365d7c
Commit
05365d7c
authored
Oct 25, 2016
by
Anirudh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moving deletion behavior from the NC into PodGC
This should be a NOP because we're just moving functionality around and thanks to #35476, the podGC controller should always run anyway.
parent
b47d862a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
14 deletions
+28
-14
controller_utils.go
pkg/controller/node/controller_utils.go
+1
-10
nodecontroller_test.go
pkg/controller/node/nodecontroller_test.go
+2
-2
gc_controller.go
pkg/controller/podgc/gc_controller.go
+25
-2
No files found.
pkg/controller/node/controller_utils.go
View file @
05365d7c
...
@@ -135,12 +135,6 @@ func (nc *NodeController) maybeDeleteTerminatingPod(obj interface{}) {
...
@@ -135,12 +135,6 @@ func (nc *NodeController) maybeDeleteTerminatingPod(obj interface{}) {
return
return
}
}
// delete terminating pods that have not yet been scheduled
if
len
(
pod
.
Spec
.
NodeName
)
==
0
{
utilruntime
.
HandleError
(
nc
.
forcefullyDeletePod
(
pod
))
return
}
nodeObj
,
found
,
err
:=
nc
.
nodeStore
.
Store
.
GetByKey
(
pod
.
Spec
.
NodeName
)
nodeObj
,
found
,
err
:=
nc
.
nodeStore
.
Store
.
GetByKey
(
pod
.
Spec
.
NodeName
)
if
err
!=
nil
{
if
err
!=
nil
{
// this can only happen if the Store.KeyFunc has a problem creating
// this can only happen if the Store.KeyFunc has a problem creating
...
@@ -150,11 +144,8 @@ func (nc *NodeController) maybeDeleteTerminatingPod(obj interface{}) {
...
@@ -150,11 +144,8 @@ func (nc *NodeController) maybeDeleteTerminatingPod(obj interface{}) {
return
return
}
}
// delete terminating pods that have been scheduled on
// if there is no such node, do nothing and let the podGC clean it up.
// nonexistent nodes
if
!
found
{
if
!
found
{
glog
.
Warningf
(
"Unable to find Node: %v, deleting all assigned Pods."
,
pod
.
Spec
.
NodeName
)
utilruntime
.
HandleError
(
nc
.
forcefullyDeletePod
(
pod
))
return
return
}
}
...
...
pkg/controller/node/nodecontroller_test.go
View file @
05365d7c
...
@@ -1723,14 +1723,14 @@ func TestCheckPod(t *testing.T) {
...
@@ -1723,14 +1723,14 @@ func TestCheckPod(t *testing.T) {
ObjectMeta
:
api
.
ObjectMeta
{
DeletionTimestamp
:
&
unversioned
.
Time
{}},
ObjectMeta
:
api
.
ObjectMeta
{
DeletionTimestamp
:
&
unversioned
.
Time
{}},
Spec
:
api
.
PodSpec
{
NodeName
:
""
},
Spec
:
api
.
PodSpec
{
NodeName
:
""
},
},
},
prune
:
tru
e
,
prune
:
fals
e
,
},
},
{
{
pod
:
api
.
Pod
{
pod
:
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
DeletionTimestamp
:
&
unversioned
.
Time
{}},
ObjectMeta
:
api
.
ObjectMeta
{
DeletionTimestamp
:
&
unversioned
.
Time
{}},
Spec
:
api
.
PodSpec
{
NodeName
:
"nonexistant"
},
Spec
:
api
.
PodSpec
{
NodeName
:
"nonexistant"
},
},
},
prune
:
tru
e
,
prune
:
fals
e
,
},
},
}
}
...
...
pkg/controller/podgc/gc_controller.go
View file @
05365d7c
...
@@ -125,6 +125,7 @@ func (gcc *PodGCController) gc() {
...
@@ -125,6 +125,7 @@ func (gcc *PodGCController) gc() {
gcc
.
gcTerminated
(
pods
)
gcc
.
gcTerminated
(
pods
)
}
}
gcc
.
gcOrphaned
(
pods
)
gcc
.
gcOrphaned
(
pods
)
gcc
.
gcUnscheduledTerminating
(
pods
)
}
}
func
isPodTerminated
(
pod
*
api
.
Pod
)
bool
{
func
isPodTerminated
(
pod
*
api
.
Pod
)
bool
{
...
@@ -168,7 +169,7 @@ func (gcc *PodGCController) gcTerminated(pods []*api.Pod) {
...
@@ -168,7 +169,7 @@ func (gcc *PodGCController) gcTerminated(pods []*api.Pod) {
wait
.
Wait
()
wait
.
Wait
()
}
}
//
cleanupOrphanedPods
deletes pods that are bound to nodes that don't exist.
//
gcOrphaned
deletes pods that are bound to nodes that don't exist.
func
(
gcc
*
PodGCController
)
gcOrphaned
(
pods
[]
*
api
.
Pod
)
{
func
(
gcc
*
PodGCController
)
gcOrphaned
(
pods
[]
*
api
.
Pod
)
{
glog
.
V
(
4
)
.
Infof
(
"GC'ing orphaned"
)
glog
.
V
(
4
)
.
Infof
(
"GC'ing orphaned"
)
...
@@ -183,7 +184,29 @@ func (gcc *PodGCController) gcOrphaned(pods []*api.Pod) {
...
@@ -183,7 +184,29 @@ func (gcc *PodGCController) gcOrphaned(pods []*api.Pod) {
if
err
:=
gcc
.
deletePod
(
pod
.
Namespace
,
pod
.
Name
);
err
!=
nil
{
if
err
:=
gcc
.
deletePod
(
pod
.
Namespace
,
pod
.
Name
);
err
!=
nil
{
utilruntime
.
HandleError
(
err
)
utilruntime
.
HandleError
(
err
)
}
else
{
}
else
{
glog
.
V
(
4
)
.
Infof
(
"Forced deletion of oprhaned Pod %s succeeded"
,
pod
.
Name
)
glog
.
V
(
4
)
.
Infof
(
"Forced deletion of orphaned Pod %s succeeded"
,
pod
.
Name
)
}
}
}
// gcUnscheduledTerminating deletes pods that are terminating and haven't been scheduled to a particular node.
func
(
gcc
*
PodGCController
)
gcUnscheduledTerminating
(
pods
[]
*
api
.
Pod
)
{
glog
.
V
(
4
)
.
Infof
(
"GC'ing unscheduled pods which are terminating."
)
for
_
,
pod
:=
range
pods
{
if
pod
.
DeletionTimestamp
==
nil
{
continue
}
if
len
(
pod
.
Spec
.
NodeName
)
>
0
{
continue
}
glog
.
V
(
2
)
.
Infof
(
"Found unscheduled terminating Pod %v not assigned to any Node. Deleting."
,
pod
.
Name
)
if
err
:=
gcc
.
deletePod
(
pod
.
Namespace
,
pod
.
Name
);
err
!=
nil
{
utilruntime
.
HandleError
(
err
)
}
else
{
glog
.
V
(
4
)
.
Infof
(
"Forced deletion of unscheduled terminating Pod %s succeeded"
,
pod
.
Name
)
}
}
}
}
}
}
...
...
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