Skip to content

Commit 649a027

Browse files
committed
fix: remove forceUmount and lazyUmount
1 parent 6c47069 commit 649a027

File tree

2 files changed

+2
-37
lines changed

2 files changed

+2
-37
lines changed

pkg/mounter/safe_mounter_unix.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,13 @@ limitations under the License.
2020
package mounter
2121

2222
import (
23-
"runtime"
24-
2523
mount "k8s.io/mount-utils"
2624
utilexec "k8s.io/utils/exec"
2725
)
2826

2927
func NewSafeMounter(removeSMBMappingDuringUnmount bool) (*mount.SafeFormatAndMount, error) {
30-
mounter := mount.New("")
31-
if runtime.GOOS == "linux" {
32-
// MounterForceUnmounter is only implemented on Linux now
33-
mounter = mounter.(mount.MounterForceUnmounter)
34-
}
3528
return &mount.SafeFormatAndMount{
36-
Interface: mounter,
29+
Interface: mount.New(""),
3730
Exec: utilexec.New(),
3831
}, nil
3932
}

pkg/smb/smb_common_linux.go

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,8 @@ limitations under the License.
2020
package smb
2121

2222
import (
23-
"fmt"
2423
"os"
25-
"os/exec"
26-
"strings"
27-
"time"
2824

29-
"k8s.io/klog/v2"
3025
mount "k8s.io/mount-utils"
3126
)
3227

@@ -39,21 +34,7 @@ func CleanupSMBMountPoint(m *mount.SafeFormatAndMount, target string, extensiveM
3934
}
4035

4136
func CleanupMountPoint(m *mount.SafeFormatAndMount, target string, extensiveMountCheck bool) error {
42-
var err error
43-
extensiveMountPointCheck := true
44-
forceUnmounter, ok := m.Interface.(mount.MounterForceUnmounter)
45-
if ok {
46-
klog.V(2).Infof("force unmount on %s", target)
47-
err = mount.CleanupMountWithForce(target, forceUnmounter, extensiveMountPointCheck, 30*time.Second)
48-
} else {
49-
err = mount.CleanupMountPoint(target, m.Interface, extensiveMountPointCheck)
50-
}
51-
52-
if err != nil && strings.Contains(err.Error(), "target is busy") {
53-
klog.Warningf("unmount on %s failed with %v, try lazy unmount", target, err)
54-
err = forceUmount(target)
55-
}
56-
return err
37+
return mount.CleanupMountPoint(target, m, extensiveMountCheck)
5738
}
5839

5940
func preparePublishPath(path string, m *mount.SafeFormatAndMount) error {
@@ -67,12 +48,3 @@ func prepareStagePath(path string, m *mount.SafeFormatAndMount) error {
6748
func Mkdir(m *mount.SafeFormatAndMount, name string, perm os.FileMode) error {
6849
return os.Mkdir(name, perm)
6950
}
70-
71-
func forceUmount(path string) error {
72-
cmd := exec.Command("umount", "-lf", path)
73-
out, cmderr := cmd.CombinedOutput()
74-
if cmderr != nil {
75-
return fmt.Errorf("lazy unmount on %s failed with %v, output: %s", path, cmderr, string(out))
76-
}
77-
return nil
78-
}

0 commit comments

Comments
 (0)