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
c3fcfd96
Commit
c3fcfd96
authored
Dec 23, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #17881 from jiangyaoguo/emit-event-when-delete-pod
Auto commit by PR queue bot
parents
4866d23f
91e0bbeb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
9 deletions
+20
-9
controller_utils.go
pkg/controller/controller_utils.go
+16
-5
controller.go
pkg/controller/daemon/controller.go
+1
-1
controller.go
pkg/controller/job/controller.go
+2
-2
replication_controller.go
pkg/controller/replication/replication_controller.go
+1
-1
No files found.
pkg/controller/controller_utils.go
View file @
c3fcfd96
...
...
@@ -231,7 +231,7 @@ type PodControlInterface interface {
// CreatePodsOnNode creates a new pod accorting to the spec on the specified node.
CreatePodsOnNode
(
nodeName
,
namespace
string
,
template
*
api
.
PodTemplateSpec
,
object
runtime
.
Object
)
error
// DeletePod deletes the pod identified by podID.
DeletePod
(
namespace
string
,
podID
string
)
error
DeletePod
(
namespace
string
,
podID
string
,
object
runtime
.
Object
)
error
}
// RealPodControl is the default implementation of PodControlInterface.
...
...
@@ -324,8 +324,19 @@ func (r RealPodControl) createPods(nodeName, namespace string, template *api.Pod
return
nil
}
func
(
r
RealPodControl
)
DeletePod
(
namespace
,
podID
string
)
error
{
return
r
.
KubeClient
.
Pods
(
namespace
)
.
Delete
(
podID
,
nil
)
func
(
r
RealPodControl
)
DeletePod
(
namespace
string
,
podID
string
,
object
runtime
.
Object
)
error
{
meta
,
err
:=
api
.
ObjectMetaFor
(
object
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"object does not have ObjectMeta, %v"
,
err
)
}
if
err
:=
r
.
KubeClient
.
Pods
(
namespace
)
.
Delete
(
podID
,
nil
);
err
!=
nil
{
r
.
Recorder
.
Eventf
(
object
,
api
.
EventTypeWarning
,
"FailedDelete"
,
"Error deleting: %v"
,
err
)
return
fmt
.
Errorf
(
"unable to delete pods: %v"
,
err
)
}
else
{
glog
.
V
(
4
)
.
Infof
(
"Controller %v deleted pod %v"
,
meta
.
Name
,
podID
)
r
.
Recorder
.
Eventf
(
object
,
api
.
EventTypeNormal
,
"SuccessfulDelete"
,
"Deleted pod: %v"
,
podID
)
}
return
nil
}
type
FakePodControl
struct
{
...
...
@@ -357,13 +368,13 @@ func (f *FakePodControl) CreatePodsOnNode(nodeName, namespace string, template *
return
nil
}
func
(
f
*
FakePodControl
)
DeletePod
(
namespace
string
,
pod
Name
string
)
error
{
func
(
f
*
FakePodControl
)
DeletePod
(
namespace
string
,
pod
ID
string
,
object
runtime
.
Object
)
error
{
f
.
Lock
()
defer
f
.
Unlock
()
if
f
.
Err
!=
nil
{
return
f
.
Err
}
f
.
DeletePodName
=
append
(
f
.
DeletePodName
,
pod
Name
)
f
.
DeletePodName
=
append
(
f
.
DeletePodName
,
pod
ID
)
return
nil
}
...
...
pkg/controller/daemon/controller.go
View file @
c3fcfd96
...
...
@@ -416,7 +416,7 @@ func (dsc *DaemonSetsController) manage(ds *extensions.DaemonSet) {
glog
.
V
(
4
)
.
Infof
(
"Pods to delete for daemon set %s: %+v"
,
ds
.
Name
,
podsToDelete
)
for
i
:=
range
podsToDelete
{
if
err
:=
dsc
.
podControl
.
DeletePod
(
ds
.
Namespace
,
podsToDelete
[
i
]);
err
!=
nil
{
if
err
:=
dsc
.
podControl
.
DeletePod
(
ds
.
Namespace
,
podsToDelete
[
i
]
,
ds
);
err
!=
nil
{
glog
.
V
(
2
)
.
Infof
(
"Failed deletion, decrementing expectations for set %q/%q"
,
ds
.
Namespace
,
ds
.
Name
)
dsc
.
expectations
.
DeletionObserved
(
dsKey
)
util
.
HandleError
(
err
)
...
...
pkg/controller/job/controller.go
View file @
c3fcfd96
...
...
@@ -346,7 +346,7 @@ func (jm *JobController) syncJob(key string) error {
for
i
:=
0
;
i
<
active
;
i
++
{
go
func
(
ix
int
)
{
defer
wait
.
Done
()
if
err
:=
jm
.
podControl
.
DeletePod
(
job
.
Namespace
,
activePods
[
ix
]
.
Name
);
err
!=
nil
{
if
err
:=
jm
.
podControl
.
DeletePod
(
job
.
Namespace
,
activePods
[
ix
]
.
Name
,
&
job
);
err
!=
nil
{
defer
util
.
HandleError
(
err
)
}
}(
i
)
...
...
@@ -440,7 +440,7 @@ func (jm *JobController) manageJob(activePods []*api.Pod, succeeded int, job *ex
for
i
:=
0
;
i
<
diff
;
i
++
{
go
func
(
ix
int
)
{
defer
wait
.
Done
()
if
err
:=
jm
.
podControl
.
DeletePod
(
job
.
Namespace
,
activePods
[
ix
]
.
Name
);
err
!=
nil
{
if
err
:=
jm
.
podControl
.
DeletePod
(
job
.
Namespace
,
activePods
[
ix
]
.
Name
,
job
);
err
!=
nil
{
defer
util
.
HandleError
(
err
)
// Decrement the expected number of deletes because the informer won't observe this deletion
jm
.
expectations
.
DeletionObserved
(
jobKey
)
...
...
pkg/controller/replication/replication_controller.go
View file @
c3fcfd96
...
...
@@ -383,7 +383,7 @@ func (rm *ReplicationManager) manageReplicas(filteredPods []*api.Pod, rc *api.Re
for
i
:=
0
;
i
<
diff
;
i
++
{
go
func
(
ix
int
)
{
defer
wait
.
Done
()
if
err
:=
rm
.
podControl
.
DeletePod
(
rc
.
Namespace
,
filteredPods
[
ix
]
.
Name
);
err
!=
nil
{
if
err
:=
rm
.
podControl
.
DeletePod
(
rc
.
Namespace
,
filteredPods
[
ix
]
.
Name
,
rc
);
err
!=
nil
{
// Decrement the expected number of deletes because the informer won't observe this deletion
glog
.
V
(
2
)
.
Infof
(
"Failed deletion, decrementing expectations for controller %q/%q"
,
rc
.
Namespace
,
rc
.
Name
)
rm
.
expectations
.
DeletionObserved
(
rcKey
)
...
...
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