|
@@ -156,11 +156,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
|
|
startCallback(&c.ProcessConfig, pid)
|
|
startCallback(&c.ProcessConfig, pid)
|
|
}
|
|
}
|
|
|
|
|
|
- oomKillNotification, err := cont.NotifyOOM()
|
|
|
|
- if err != nil {
|
|
|
|
- oomKillNotification = nil
|
|
|
|
- log.Warnf("Your kernel does not support OOM notifications: %s", err)
|
|
|
|
- }
|
|
|
|
|
|
+ oom := notifyOnOOM(cont)
|
|
waitF := p.Wait
|
|
waitF := p.Wait
|
|
if nss := cont.Config().Namespaces; !nss.Contains(configs.NEWPID) {
|
|
if nss := cont.Config().Namespaces; !nss.Contains(configs.NEWPID) {
|
|
// we need such hack for tracking processes with inerited fds,
|
|
// we need such hack for tracking processes with inerited fds,
|
|
@@ -176,12 +172,24 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
|
|
ps = execErr.ProcessState
|
|
ps = execErr.ProcessState
|
|
}
|
|
}
|
|
cont.Destroy()
|
|
cont.Destroy()
|
|
-
|
|
|
|
- _, oomKill := <-oomKillNotification
|
|
|
|
-
|
|
|
|
|
|
+ _, oomKill := <-oom
|
|
return execdriver.ExitStatus{ExitCode: utils.ExitStatus(ps.Sys().(syscall.WaitStatus)), OOMKilled: oomKill}, nil
|
|
return execdriver.ExitStatus{ExitCode: utils.ExitStatus(ps.Sys().(syscall.WaitStatus)), OOMKilled: oomKill}, nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// notifyOnOOM returns a channel that signals if the container received an OOM notification
|
|
|
|
+// for any process. If it is unable to subscribe to OOM notifications then a closed
|
|
|
|
+// channel is returned as it will be non-blocking and return the correct result when read.
|
|
|
|
+func notifyOnOOM(container libcontainer.Container) <-chan struct{} {
|
|
|
|
+ oom, err := container.NotifyOOM()
|
|
|
|
+ if err != nil {
|
|
|
|
+ log.Warnf("Your kernel does not support OOM notifications: %s", err)
|
|
|
|
+ c := make(chan struct{})
|
|
|
|
+ close(c)
|
|
|
|
+ return c
|
|
|
|
+ }
|
|
|
|
+ return oom
|
|
|
|
+}
|
|
|
|
+
|
|
func waitInPIDHost(p *libcontainer.Process, c libcontainer.Container) func() (*os.ProcessState, error) {
|
|
func waitInPIDHost(p *libcontainer.Process, c libcontainer.Container) func() (*os.ProcessState, error) {
|
|
return func() (*os.ProcessState, error) {
|
|
return func() (*os.ProcessState, error) {
|
|
pid, err := p.Pid()
|
|
pid, err := p.Pid()
|