From 0b15e03da04b13bbff875b988d019b74e970ad64 Mon Sep 17 00:00:00 2001 From: Lei Jitang Date: Tue, 5 Jul 2016 07:43:56 -0400 Subject: [PATCH] set default shim if shim is nil for backward compatibility Signed-off-by: Lei Jitang --- runtime/container.go | 7 ++++++- supervisor/supervisor.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/runtime/container.go b/runtime/container.go index 8375905..5919485 100644 --- a/runtime/container.go +++ b/runtime/container.go @@ -143,7 +143,7 @@ func New(opts ContainerOpts) (Container, error) { } // Load return a new container from the matchin state file on disk. -func Load(root, id string, timeout time.Duration) (Container, error) { +func Load(root, id, shimName string, timeout time.Duration) (Container, error) { var s state f, err := os.Open(filepath.Join(root, id, StateFile)) if err != nil { @@ -165,6 +165,11 @@ func Load(root, id string, timeout time.Duration) (Container, error) { processes: make(map[string]*process), timeout: timeout, } + + if c.shim == "" { + c.shim = shimName + } + dirs, err := ioutil.ReadDir(filepath.Join(root, id)) if err != nil { return nil, err diff --git a/supervisor/supervisor.go b/supervisor/supervisor.go index 67b7adc..f80dee3 100644 --- a/supervisor/supervisor.go +++ b/supervisor/supervisor.go @@ -307,7 +307,7 @@ func (s *Supervisor) restore() error { continue } id := d.Name() - container, err := runtime.Load(s.stateDir, id, s.timeout) + container, err := runtime.Load(s.stateDir, id, s.shim, s.timeout) if err != nil { return err }