mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +00:00
kubelet/dockertools: clear container reference when killing a container.
This commit is contained in:
parent
00e34429e0
commit
6ced66249d
@ -46,8 +46,6 @@ func (c *RefManager) SetRef(id string, ref *api.ObjectReference) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ClearRef forgets the given container id and its associated container reference.
|
// ClearRef forgets the given container id and its associated container reference.
|
||||||
// TODO(yifan): This is currently never called. Consider to remove this function,
|
|
||||||
// or figure out when to clear the references.
|
|
||||||
func (c *RefManager) ClearRef(id string) {
|
func (c *RefManager) ClearRef(id string) {
|
||||||
c.Lock()
|
c.Lock()
|
||||||
defer c.Unlock()
|
defer c.Unlock()
|
||||||
|
@ -1294,6 +1294,7 @@ func (dm *DockerManager) killContainer(containerID types.UID, container *api.Con
|
|||||||
} else {
|
} else {
|
||||||
// TODO: pass reason down here, and state, or move this call up the stack.
|
// TODO: pass reason down here, and state, or move this call up the stack.
|
||||||
dm.recorder.Eventf(ref, "Killing", "Killing with docker id %v", util.ShortenString(ID, 12))
|
dm.recorder.Eventf(ref, "Killing", "Killing with docker id %v", util.ShortenString(ID, 12))
|
||||||
|
dm.containerRefManager.ClearRef(ID)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -726,6 +726,7 @@ func (r *runtime) GetPods(all bool) ([]*kubecontainer.Pod, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// KillPod invokes 'systemctl kill' to kill the unit that runs the pod.
|
// KillPod invokes 'systemctl kill' to kill the unit that runs the pod.
|
||||||
|
// TODO(yifan): Handle network plugin.
|
||||||
func (r *runtime) KillPod(pod *api.Pod, runningPod kubecontainer.Pod) error {
|
func (r *runtime) KillPod(pod *api.Pod, runningPod kubecontainer.Pod) error {
|
||||||
glog.V(4).Infof("Rkt is killing pod: name %q.", runningPod.Name)
|
glog.V(4).Infof("Rkt is killing pod: name %q.", runningPod.Name)
|
||||||
serviceName := makePodServiceFileName(runningPod.ID)
|
serviceName := makePodServiceFileName(runningPod.ID)
|
||||||
@ -948,7 +949,6 @@ func (r *runtime) SyncPod(pod *api.Pod, runningPod kubecontainer.Pod, podStatus
|
|||||||
}
|
}
|
||||||
|
|
||||||
if restartPod {
|
if restartPod {
|
||||||
// TODO(yifan): Handle network plugin.
|
|
||||||
if err := r.KillPod(pod, runningPod); err != nil {
|
if err := r.KillPod(pod, runningPod); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user