feat: use force unmount to fix unmount failure issie

This commit is contained in:
andyzhangx 2022-12-24 02:17:22 +00:00
parent f19db6ef3e
commit ba1f1acedc
2 changed files with 11 additions and 2 deletions

View File

@ -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),

View File

@ -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)
}