mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Ensure state is destroyed on daemont restart
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
0c7b51089c
commit
a5f7c4aa31
2 changed files with 6 additions and 21 deletions
|
@ -273,19 +273,8 @@ func (daemon *Daemon) register(container *Container, updateSuffixarray bool) err
|
||||||
if err := container.ToDisk(); err != nil {
|
if err := container.ToDisk(); err != nil {
|
||||||
logrus.Debugf("saving stopped state to disk %s", err)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -268,29 +268,25 @@ func (d *driver) Unpause(c *execdriver.Command) error {
|
||||||
|
|
||||||
func (d *driver) Terminate(c *execdriver.Command) error {
|
func (d *driver) Terminate(c *execdriver.Command) error {
|
||||||
defer d.cleanContainer(c.ID)
|
defer d.cleanContainer(c.ID)
|
||||||
// lets check the start time for the process
|
container, err := d.factory.Load(c.ID)
|
||||||
active := d.activeContainers[c.ID]
|
if err != nil {
|
||||||
if active == nil {
|
return err
|
||||||
return fmt.Errorf("active container for %s does not exist", c.ID)
|
|
||||||
}
|
}
|
||||||
state, err := active.State()
|
defer container.Destroy()
|
||||||
|
state, err := container.State()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
pid := state.InitProcessPid
|
pid := state.InitProcessPid
|
||||||
|
|
||||||
currentStartTime, err := system.GetProcessStartTime(pid)
|
currentStartTime, err := system.GetProcessStartTime(pid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if state.InitProcessStartTime == currentStartTime {
|
if state.InitProcessStartTime == currentStartTime {
|
||||||
err = syscall.Kill(pid, 9)
|
err = syscall.Kill(pid, 9)
|
||||||
syscall.Wait4(pid, nil, 0, nil)
|
syscall.Wait4(pid, nil, 0, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *driver) Info(id string) execdriver.Info {
|
func (d *driver) Info(id string) execdriver.Info {
|
||||||
|
|
Loading…
Add table
Reference in a new issue