Skip to content

Commit 487129d

Browse files
committed
mount/RecursiveUnmount: rm logrus, save error
Since I use fmt.Error("%w") which requires go 1.13, let's fail to build on an older golang version. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 173ef0d commit 487129d

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

mount/mount.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
// +build go1.13
2+
13
package mount
24

35
import (
6+
"fmt"
47
"sort"
58
"strconv"
6-
7-
"github.com/sirupsen/logrus"
89
)
910

1011
// mountError records an error from mount or unmount operation
@@ -95,18 +96,21 @@ func RecursiveUnmount(target string) error {
9596
return len(mounts[i].Mountpoint) > len(mounts[j].Mountpoint)
9697
})
9798

99+
var suberr error
98100
for i, m := range mounts {
99-
logrus.Debugf("Trying to unmount %s", m.Mountpoint)
100101
err = unmount(m.Mountpoint, mntDetach)
101102
if err != nil {
102103
if i == len(mounts)-1 { // last mount
103-
return err
104+
return fmt.Errorf("%w (possible cause: %s)", err, suberr)
105+
}
106+
// This is a submount, we can ignore the error for now,
107+
// the final unmount will fail if this is a real problem.
108+
// With that in mind, the _first_ failed unmount error
109+
// might be the real error cause, so let's keep it.
110+
if suberr == nil {
111+
suberr = err
104112
}
105-
// This is some submount, we can ignore this error for now, the final unmount will fail if this is a real problem
106-
logrus.WithError(err).Warnf("Failed to unmount submount %s", m.Mountpoint)
107113
}
108-
109-
logrus.Debugf("Unmounted %s", m.Mountpoint)
110114
}
111115
return nil
112116
}

0 commit comments

Comments
 (0)