Skip to content

Commit 41e57b3

Browse files
Copilotandyzhangx
andcommitted
Improve cleanup logic consistency in NodePublishVolume
- Use same force unmount pattern as NodeUnpublishVolume for cleanup - Ensures proper cleanup even if mount is stuck Co-authored-by: andyzhangx <[email protected]>
1 parent 1bc36a4 commit 41e57b3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/nfs/nodeserver.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,12 @@ func (ns *NodeServer) NodePublishVolume(_ context.Context, req *csi.NodePublishV
150150
klog.V(2).Infof("NodePublishVolume: remounting targetPath(%s) with security options(%v)", targetPath, securityOpts)
151151
if err := ns.mounter.Mount("", targetPath, "", securityOpts); err != nil {
152152
// Attempt to cleanup the bind mount on failure
153-
mount.CleanupMountPoint(targetPath, ns.mounter, false)
153+
forceUnmounter, ok := ns.mounter.(mount.MounterForceUnmounter)
154+
if ok {
155+
mount.CleanupMountWithForce(targetPath, forceUnmounter, false, 30*time.Second)
156+
} else {
157+
mount.CleanupMountPoint(targetPath, ns.mounter, false)
158+
}
154159
if os.IsPermission(err) {
155160
return nil, status.Error(codes.PermissionDenied, err.Error())
156161
}

0 commit comments

Comments
 (0)