Cleanup container reg for lxc special case

The lxc code here is doing the exact same thing on calling
execdriver.Terminate, so let's just use that.

Also removes some dead comments originally introduced
50144aeb42 but no longer relevant since we
have restart policies.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
Brian Goff 2015-05-04 13:49:28 -04:00
parent a1aff84480
commit 44cd599e29

View file

@ -22,7 +22,6 @@ import (
"github.com/docker/docker/daemon/events" "github.com/docker/docker/daemon/events"
"github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/daemon/execdriver"
"github.com/docker/docker/daemon/execdriver/execdrivers" "github.com/docker/docker/daemon/execdriver/execdrivers"
"github.com/docker/docker/daemon/execdriver/lxc"
"github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/daemon/graphdriver"
_ "github.com/docker/docker/daemon/graphdriver/vfs" _ "github.com/docker/docker/daemon/graphdriver/vfs"
"github.com/docker/docker/daemon/network" "github.com/docker/docker/daemon/network"
@ -208,25 +207,16 @@ func (daemon *Daemon) register(container *Container, updateSuffixarray bool) err
container.registerVolumes() container.registerVolumes()
// FIXME: if the container is supposed to be running but is not, auto restart it?
// if so, then we need to restart monitor and init a new lock
// If the container is supposed to be running, make sure of it
if container.IsRunning() { if container.IsRunning() {
logrus.Debugf("killing old running container %s", container.ID) logrus.Debugf("killing old running container %s", container.ID)
container.SetStopped(&execdriver.ExitStatus{ExitCode: 0}) container.SetStopped(&execdriver.ExitStatus{ExitCode: 0})
// We only have to handle this for lxc because the other drivers will ensure that // use the current driver and ensure that the container is dead x.x
// no processes are left when docker dies cmd := &execdriver.Command{
if container.ExecDriver == "" || strings.Contains(container.ExecDriver, "lxc") { ID: container.ID,
lxc.KillLxc(container.ID, 9)
} else {
// use the current driver and ensure that the container is dead x.x
cmd := &execdriver.Command{
ID: container.ID,
}
daemon.execDriver.Terminate(cmd)
} }
daemon.execDriver.Terminate(cmd)
if err := container.Unmount(); err != nil { if err := container.Unmount(); err != nil {
logrus.Debugf("unmount error %s", err) logrus.Debugf("unmount error %s", err)