|
@@ -154,12 +154,39 @@ func (runtime *Runtime) Register(container *Container) error {
|
|
// if so, then we need to restart monitor and init a new lock
|
|
// 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 the container is supposed to be running, make sure of it
|
|
if container.State.IsRunning() {
|
|
if container.State.IsRunning() {
|
|
- info := runtime.execDriver.Info(container.ID)
|
|
|
|
|
|
+ if container.State.IsGhost() {
|
|
|
|
+ utils.Debugf("killing ghost %s", container.ID)
|
|
|
|
+
|
|
|
|
+ existingPid := container.State.Pid
|
|
|
|
+ container.State.SetGhost(false)
|
|
|
|
+ container.State.SetStopped(0)
|
|
|
|
|
|
|
|
+ if container.ExecDriver == "" || strings.Contains(container.ExecDriver, "lxc") {
|
|
|
|
+ lxc.KillLxc(container.ID, 9)
|
|
|
|
+ } else {
|
|
|
|
+ command := &execdriver.Command{
|
|
|
|
+ ID: container.ID,
|
|
|
|
+ }
|
|
|
|
+ command.Process = &os.Process{Pid: existingPid}
|
|
|
|
+ runtime.execDriver.Kill(command, 9)
|
|
|
|
+ }
|
|
|
|
+ // ensure that the filesystem is also unmounted
|
|
|
|
+ unmountVolumesForContainer(container)
|
|
|
|
+ if err := container.Unmount(); err != nil {
|
|
|
|
+ utils.Debugf("ghost unmount error %s", err)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ info := runtime.execDriver.Info(container.ID)
|
|
if !info.IsRunning() {
|
|
if !info.IsRunning() {
|
|
utils.Debugf("Container %s was supposed to be running but is not.", container.ID)
|
|
utils.Debugf("Container %s was supposed to be running but is not.", container.ID)
|
|
if runtime.config.AutoRestart {
|
|
if runtime.config.AutoRestart {
|
|
utils.Debugf("Restarting")
|
|
utils.Debugf("Restarting")
|
|
|
|
+ unmountVolumesForContainer(container)
|
|
|
|
+ if err := container.Unmount(); err != nil {
|
|
|
|
+ utils.Debugf("restart unmount error %s", err)
|
|
|
|
+ }
|
|
|
|
+
|
|
container.State.SetGhost(false)
|
|
container.State.SetGhost(false)
|
|
container.State.SetStopped(0)
|
|
container.State.SetStopped(0)
|
|
if err := container.Start(); err != nil {
|
|
if err := container.Start(); err != nil {
|
|
@@ -172,15 +199,6 @@ func (runtime *Runtime) Register(container *Container) error {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- utils.Debugf("Reconnecting to container %v", container.ID)
|
|
|
|
-
|
|
|
|
- if err := container.allocateNetwork(); err != nil {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- container.waitLock = make(chan struct{})
|
|
|
|
- go container.monitor(nil)
|
|
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
// When the container is not running, we still initialize the waitLock
|
|
// When the container is not running, we still initialize the waitLock
|
|
@@ -447,6 +465,7 @@ func (runtime *Runtime) Create(config *runconfig.Config, name string) (*Containe
|
|
NetworkSettings: &NetworkSettings{},
|
|
NetworkSettings: &NetworkSettings{},
|
|
Name: name,
|
|
Name: name,
|
|
Driver: runtime.driver.String(),
|
|
Driver: runtime.driver.String(),
|
|
|
|
+ ExecDriver: runtime.execDriver.Name(),
|
|
}
|
|
}
|
|
container.root = runtime.containerRoot(container.ID)
|
|
container.root = runtime.containerRoot(container.ID)
|
|
// Step 1: create the container directory.
|
|
// Step 1: create the container directory.
|
|
@@ -834,10 +853,6 @@ func (runtime *Runtime) Kill(c *Container, sig int) error {
|
|
return runtime.execDriver.Kill(c.command, sig)
|
|
return runtime.execDriver.Kill(c.command, sig)
|
|
}
|
|
}
|
|
|
|
|
|
-func (runtime *Runtime) RestoreCommand(c *Container) error {
|
|
|
|
- return runtime.execDriver.Restore(c.command)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// Nuke kills all containers then removes all content
|
|
// Nuke kills all containers then removes all content
|
|
// from the content root, including images, volumes and
|
|
// from the content root, including images, volumes and
|
|
// container filesystems.
|
|
// container filesystems.
|