1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #6808 from vieux/pr_6806

Add backwards READ compatibility for the old libcontainer API
This commit is contained in:
Victor Vieux 2014-07-02 10:51:27 -07:00
commit 8ea3589287
2 changed files with 20 additions and 5 deletions

View file

@ -172,6 +172,13 @@ func (d *driver) Unpause(c *execdriver.Command) error {
func (d *driver) Terminate(p *execdriver.Command) error { func (d *driver) Terminate(p *execdriver.Command) error {
// lets check the start time for the process // lets check the start time for the process
state, err := libcontainer.GetState(filepath.Join(d.root, p.ID)) state, err := libcontainer.GetState(filepath.Join(d.root, p.ID))
if err != nil {
if !os.IsNotExist(err) {
return err
}
// TODO: Remove this part for version 1.2.0
// This is added only to ensure smooth upgrades from pre 1.1.0 to 1.1.0
data, err := ioutil.ReadFile(filepath.Join(d.root, p.ID, "start"))
if err != nil { if err != nil {
// if we don't have the data on disk then we can assume the process is gone // if we don't have the data on disk then we can assume the process is gone
// because this is only removed after we know the process has stopped // because this is only removed after we know the process has stopped
@ -180,6 +187,8 @@ func (d *driver) Terminate(p *execdriver.Command) error {
} }
return err return err
} }
state = &libcontainer.State{InitStartTime: string(data)}
}
currentStartTime, err := system.GetProcessStartTime(p.Process.Pid) currentStartTime, err := system.GetProcessStartTime(p.Process.Pid)
if err != nil { if err != nil {

View file

@ -1,6 +1,7 @@
package native package native
import ( import (
"os"
"path/filepath" "path/filepath"
"github.com/docker/libcontainer" "github.com/docker/libcontainer"
@ -18,5 +19,10 @@ func (i *info) IsRunning() bool {
if _, err := libcontainer.GetState(filepath.Join(i.driver.root, i.ID)); err == nil { if _, err := libcontainer.GetState(filepath.Join(i.driver.root, i.ID)); err == nil {
return true return true
} }
// TODO: Remove this part for version 1.2.0
// This is added only to ensure smooth upgrades from pre 1.1.0 to 1.1.0
if _, err := os.Stat(filepath.Join(i.driver.root, i.ID, "pid")); err == nil {
return true
}
return false return false
} }