Quellcode durchsuchen

Merge pull request #40637 from kolyshkin/ensure-remove-all

EnsureRemoveAll, RecursiveUnmount: don't call Mounted around Unmount
Sebastiaan van Stijn vor 5 Jahren
Ursprung
Commit
8bbba72499
2 geänderte Dateien mit 3 neuen und 9 gelöschten Zeilen
  1. 1 3
      pkg/mount/mount.go
  2. 2 6
      pkg/system/rm.go

+ 1 - 3
pkg/mount/mount.go

@@ -139,9 +139,7 @@ func RecursiveUnmount(target string) error {
 		err = unmount(m.Mountpoint, mntDetach)
 		if err != nil {
 			if i == len(mounts)-1 { // last mount
-				if mounted, e := Mounted(m.Mountpoint); e != nil || mounted {
-					return err
-				}
+				return err
 			} else {
 				// This is some submount, we can ignore this error for now, the final unmount will fail if this is a real problem
 				logrus.WithError(err).Warnf("Failed to unmount submount %s", m.Mountpoint)

+ 2 - 6
pkg/system/rm.go

@@ -63,12 +63,8 @@ func EnsureRemoveAll(dir string) error {
 			return err
 		}
 
-		if mounted, _ := mount.Mounted(pe.Path); mounted {
-			if e := mount.Unmount(pe.Path); e != nil {
-				if mounted, _ := mount.Mounted(pe.Path); mounted {
-					return errors.Wrapf(e, "error while removing %s", dir)
-				}
-			}
+		if e := mount.Unmount(pe.Path); e != nil {
+			return errors.Wrapf(e, "error while removing %s", dir)
 		}
 
 		if exitOnErr[pe.Path] == maxRetry {