Merge pull request #214 from rajasec/restorefix

Restore container cleanup
This commit is contained in:
Alexander Morozov 2015-08-28 10:49:09 -07:00
commit 98e6e70cf3
1 changed files with 11 additions and 0 deletions

View File

@ -4,6 +4,7 @@ package main
import (
"os"
"path/filepath"
"github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
@ -89,6 +90,16 @@ func restoreContainer(context *cli.Context, spec *specs.LinuxSpec, config *confi
handler := newSignalHandler(tty)
defer handler.Close()
if err := container.Restore(process, options); err != nil {
cstatus, cerr := container.Status()
if cerr != nil {
logrus.Error(cerr)
}
if cstatus == libcontainer.Destroyed {
dest := filepath.Join(context.GlobalString("root"), context.GlobalString("id"))
if errVal := os.RemoveAll(dest); errVal != nil {
logrus.Error(errVal)
}
}
return -1, err
}
return handler.forward(process)