Fix some issues with locking on the container

- Fix OOM event updating healthchecks and persisting container state
without locks
- Fix healthchecks being updated without locks on container stop

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 972cb4978795029131697bd3b3746e321eec5c13
Component: engine
This commit is contained in:
Brian Goff
2017-11-21 12:41:43 -05:00
parent 6ad432f442
commit b26b223eb7
3 changed files with 6 additions and 2 deletions
+2
View File
@@ -64,6 +64,8 @@ func (daemon *Daemon) killWithSignal(container *containerpkg.Container, sig int)
container.Lock()
defer container.Unlock()
daemon.stopHealthchecks(container)
if !container.Running {
return errNotRunning(container.ID)
}
+4
View File
@@ -39,10 +39,14 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerd.EventType, ei libc
if runtime.GOOS == "windows" {
return errors.New("received StateOOM from libcontainerd on Windows. This should never happen")
}
c.Lock()
defer c.Unlock()
daemon.updateHealthMonitor(c)
if err := c.CheckpointTo(daemon.containersReplica); err != nil {
return err
}
daemon.LogContainerEvent(c, "oom")
case libcontainerd.EventExit:
if int(ei.Pid) == c.Pid {
-2
View File
@@ -43,8 +43,6 @@ func (daemon *Daemon) containerStop(container *containerpkg.Container, seconds i
return nil
}
daemon.stopHealthchecks(container)
stopSignal := container.StopSignal()
// 1. Send a stop signal
if err := daemon.killPossiblyDeadProcess(container, stopSignal); err != nil {