rkt: Don't return if the service file doesn't exist when killing the pod.

Remove an unused logic. Also this prevents the KillPod() from failing
when the service file doesn't exist. E.g., it can be removed by garbage
collection in a rare case:

1, There are already more than `gcPolicy.MaxContainers` containers running
   on the host.
2, The new pod(A) starts to run but doesn't enter 'RUNNING' state yet.
3, GC is triggered, and it sees the pod(A) is in an inactive state (not running),
   and the it needs to remove the pod to force the `gcPolicy.MaxContainers`.
4, GC fails to remove the pod because `rkt rm` fails when the pod is running,
   but it removes the service file anyway.
5, Follow up KillPod() call will fail because it cannot find the service file
   on disk.

Also this is possible only when the pod has been in prepared state for longer
than 1 min, which sounds like another issue.
This commit is contained in:
Yifan Gu 2016-07-18 14:48:13 -07:00
parent 8eb0cf5039
commit b212662c1e

View File

@ -1651,13 +1651,6 @@ func (r *Runtime) KillPod(pod *api.Pod, runningPod kubecontainer.Pod, gracePerio
r.containerRefManager.ClearRef(c.ID) r.containerRefManager.ClearRef(c.ID)
} }
// Touch the systemd service file to update the mod time so it will
// not be garbage collected too soon.
if err := r.os.Chtimes(serviceFile, time.Now(), time.Now()); err != nil {
glog.Errorf("rkt: Failed to change the modification time of the service file %q: %v", serviceName, err)
return err
}
// Since all service file have 'KillMode=mixed', the processes in // Since all service file have 'KillMode=mixed', the processes in
// the unit's cgroup will receive a SIGKILL if the normal stop timeouts. // the unit's cgroup will receive a SIGKILL if the normal stop timeouts.
reschan := make(chan string) reschan := make(chan string)