Merge pull request #53 from shykes/improve_cleanup

Improve aufs cleanup and debugging
This commit is contained in:
Michael Crosby 2013-11-19 17:16:36 -08:00
commit d4ef551d65
2 changed files with 23 additions and 6 deletions

View file

@ -182,14 +182,17 @@ func (a *Driver) Remove(id string) error {
return err
}
realPath := path.Join(a.rootPath(), p, id)
if err := os.Rename(realPath, tmp); err != nil {
if err := os.Rename(realPath, tmp); err != nil && !os.IsNotExist(err) {
return err
}
defer os.RemoveAll(tmp)
}
// Remove the layers file for the id
return os.Remove(path.Join(a.rootPath(), "layers", id))
if err := os.Remove(path.Join(a.rootPath(), "layers", id)); err != nil && !os.IsNotExist(err) {
return err
}
return nil
}
// Return the rootfs path for the id
@ -300,7 +303,7 @@ func (a *Driver) Cleanup() error {
}
for _, id := range ids {
if err := a.unmount(id); err != nil {
return err
utils.Errorf("Unmounting %s: %s", utils.TruncateID(id), err)
}
}
return nil

View file

@ -729,9 +729,23 @@ func NewRuntimeFromDirectory(config *DaemonConfig) (*Runtime, error) {
}
func (runtime *Runtime) Close() error {
runtime.networkManager.Close()
runtime.driver.Cleanup()
return runtime.containerGraph.Close()
errorsStrings := []string{}
if err := runtime.networkManager.Close(); err != nil {
utils.Errorf("runtime.networkManager.Close(): %s", err.Error())
errorsStrings = append(errorsStrings, err.Error())
}
if err := runtime.driver.Cleanup(); err != nil {
utils.Errorf("runtime.driver.Cleanup(): %s", err.Error())
errorsStrings = append(errorsStrings, err.Error())
}
if err := runtime.containerGraph.Close(); err != nil {
utils.Errorf("runtime.containerGraph.Close(): %s", err.Error())
errorsStrings = append(errorsStrings, err.Error())
}
if len(errorsStrings) > 0 {
return fmt.Errorf("%s", strings.Join(errorsStrings, ", "))
}
return nil
}
func (runtime *Runtime) Mount(container *Container) error {