Skip to content

Commit ba1f1ac

Browse files
committed
feat: use force unmount to fix unmount failure issie
1 parent f19db6e commit ba1f1ac

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

pkg/nfs/nfs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func (n *Driver) Run(testMode bool) {
108108
}
109109
klog.V(2).Infof("\nDRIVER INFORMATION:\n-------------------\n%s\n\nStreaming logs below:", versionMeta)
110110

111-
n.ns = NewNodeServer(n, mount.New(""))
111+
n.ns = NewNodeServer(n, mount.New("").(mount.MounterForceUnmounter))
112112
s := NewNonBlockingGRPCServer()
113113
s.Start(n.endpoint,
114114
NewDefaultIdentityServer(n),

pkg/nfs/nodeserver.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"os"
2222
"strconv"
2323
"strings"
24+
"time"
2425

2526
"github.com/container-storage-interface/spec/lib/go/csi"
2627
"golang.org/x/net/context"
@@ -154,7 +155,15 @@ func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu
154155
}
155156

156157
klog.V(2).Infof("NodeUnpublishVolume: unmounting volume %s on %s", volumeID, targetPath)
157-
err := mount.CleanupMountPoint(targetPath, ns.mounter, true /*extensiveMountPointCheck*/)
158+
var err error
159+
extensiveMountPointCheck := true
160+
forceUnmounter, ok := ns.mounter.(mount.MounterForceUnmounter)
161+
if ok {
162+
klog.V(2).Infof("force unmount %s on %s", volumeID, targetPath)
163+
err = mount.CleanupMountWithForce(targetPath, forceUnmounter, extensiveMountPointCheck, 30*time.Second)
164+
} else {
165+
err = mount.CleanupMountPoint(targetPath, ns.mounter, extensiveMountPointCheck)
166+
}
158167
if err != nil {
159168
return nil, status.Errorf(codes.Internal, "failed to unmount target %q: %v", targetPath, err)
160169
}

0 commit comments

Comments
 (0)