Selaa lähdekoodia

Merge pull request #53 from shykes/improve_cleanup

Improve aufs cleanup and debugging
Michael Crosby 11 vuotta sitten
vanhempi
commit
d4ef551d65
2 muutettua tiedostoa jossa 23 lisäystä ja 6 poistoa
  1. 6 3
      graphdriver/aufs/aufs.go
  2. 17 3
      runtime.go

+ 6 - 3
graphdriver/aufs/aufs.go

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

+ 17 - 3
runtime.go

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