From a5f7c4aa31fa1ee2a3bebf4d38f5fda7a4a28a0d Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Wed, 15 Apr 2015 17:39:34 -0700 Subject: [PATCH] Ensure state is destroyed on daemont restart Signed-off-by: Michael Crosby --- daemon/daemon.go | 13 +------------ daemon/execdriver/native/driver.go | 14 +++++--------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/daemon/daemon.go b/daemon/daemon.go index e2ca568052..bf8eef6dc0 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -273,19 +273,8 @@ func (daemon *Daemon) register(container *Container, updateSuffixarray bool) err if err := container.ToDisk(); err != nil { logrus.Debugf("saving stopped state to disk %s", err) } - - info := daemon.execDriver.Info(container.ID) - if !info.IsRunning() { - logrus.Debugf("Container %s was supposed to be running but is not.", container.ID) - - logrus.Debug("Marking as stopped") - - container.SetStopped(&execdriver.ExitStatus{ExitCode: -127}) - if err := container.ToDisk(); err != nil { - return err - } - } } + return nil } diff --git a/daemon/execdriver/native/driver.go b/daemon/execdriver/native/driver.go index 6caa78390f..fba22c1c21 100644 --- a/daemon/execdriver/native/driver.go +++ b/daemon/execdriver/native/driver.go @@ -268,29 +268,25 @@ func (d *driver) Unpause(c *execdriver.Command) error { func (d *driver) Terminate(c *execdriver.Command) error { defer d.cleanContainer(c.ID) - // lets check the start time for the process - active := d.activeContainers[c.ID] - if active == nil { - return fmt.Errorf("active container for %s does not exist", c.ID) + container, err := d.factory.Load(c.ID) + if err != nil { + return err } - state, err := active.State() + defer container.Destroy() + state, err := container.State() if err != nil { return err } pid := state.InitProcessPid - currentStartTime, err := system.GetProcessStartTime(pid) if err != nil { return err } - if state.InitProcessStartTime == currentStartTime { err = syscall.Kill(pid, 9) syscall.Wait4(pid, nil, 0, nil) } - return err - } func (d *driver) Info(id string) execdriver.Info {