From cccb64e8633eee309e6ce33c3bb41614edd70d81 Mon Sep 17 00:00:00 2001 From: Tibor Vass Date: Tue, 1 Jul 2014 19:14:22 -0400 Subject: [PATCH] Add backwards READ compatibility for the old libcontainer API Docker-DCO-1.1-Signed-off-by: Tibor Vass (github: tiborvass) --- daemon/execdriver/native/driver.go | 19 ++++++++++++++----- daemon/execdriver/native/info.go | 6 ++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/daemon/execdriver/native/driver.go b/daemon/execdriver/native/driver.go index 1f27ef77b3..b789cc072d 100644 --- a/daemon/execdriver/native/driver.go +++ b/daemon/execdriver/native/driver.go @@ -173,12 +173,21 @@ func (d *driver) Terminate(p *execdriver.Command) error { // lets check the start time for the process state, err := libcontainer.GetState(filepath.Join(d.root, p.ID)) if err != nil { - // 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 - if os.IsNotExist(err) { - return nil + if !os.IsNotExist(err) { + return 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.ReadAll(filepath.Join(d.root, p.ID, "start")) + if err != nil { + // 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 + if os.IsNotExist(err) { + return nil + } + return err + } + state.InitStartTime = string(data) } currentStartTime, err := system.GetProcessStartTime(p.Process.Pid) diff --git a/daemon/execdriver/native/info.go b/daemon/execdriver/native/info.go index 693a455a41..c34d0297b1 100644 --- a/daemon/execdriver/native/info.go +++ b/daemon/execdriver/native/info.go @@ -1,6 +1,7 @@ package native import ( + "os" "path/filepath" "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 { 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 }