set default shim if shim is nil for backward compatibility

Signed-off-by: Lei Jitang <leijitang@huawei.com>
This commit is contained in:
Lei Jitang 2016-07-05 07:43:56 -04:00
parent 1b3a81545c
commit 0b15e03da0
2 changed files with 7 additions and 2 deletions

View file

@ -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

View file

@ -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
}