diff --git a/pkg/nfs/nfs.go b/pkg/nfs/nfs.go index 1ccd04c6..9ecd0e7e 100644 --- a/pkg/nfs/nfs.go +++ b/pkg/nfs/nfs.go @@ -108,7 +108,7 @@ func (n *Driver) Run(testMode bool) { } klog.V(2).Infof("\nDRIVER INFORMATION:\n-------------------\n%s\n\nStreaming logs below:", versionMeta) - n.ns = NewNodeServer(n, mount.New("")) + n.ns = NewNodeServer(n, mount.New("").(mount.MounterForceUnmounter)) s := NewNonBlockingGRPCServer() s.Start(n.endpoint, NewDefaultIdentityServer(n), diff --git a/pkg/nfs/nodeserver.go b/pkg/nfs/nodeserver.go index 690c3f0a..78e34991 100644 --- a/pkg/nfs/nodeserver.go +++ b/pkg/nfs/nodeserver.go @@ -21,6 +21,7 @@ import ( "os" "strconv" "strings" + "time" "github.com/container-storage-interface/spec/lib/go/csi" "golang.org/x/net/context" @@ -154,7 +155,15 @@ func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu } klog.V(2).Infof("NodeUnpublishVolume: unmounting volume %s on %s", volumeID, targetPath) - err := mount.CleanupMountPoint(targetPath, ns.mounter, true /*extensiveMountPointCheck*/) + var err error + extensiveMountPointCheck := true + forceUnmounter, ok := ns.mounter.(mount.MounterForceUnmounter) + if ok { + klog.V(2).Infof("force unmount %s on %s", volumeID, targetPath) + err = mount.CleanupMountWithForce(targetPath, forceUnmounter, extensiveMountPointCheck, 30*time.Second) + } else { + err = mount.CleanupMountPoint(targetPath, ns.mounter, extensiveMountPointCheck) + } if err != nil { return nil, status.Errorf(codes.Internal, "failed to unmount target %q: %v", targetPath, err) }