@@ -448,6 +448,11 @@ func (ns *NodeServer) NodePublishVolume(_ context.Context, req *csi.NodePublishV
448448 return nil , status .Error (codes .Internal , err .Error ())
449449 }
450450
451+ // Mount a tmpfs which is going to serve as a fixed point to allow rebinding fuse whenever necessary
452+ if err := ns .mounter .Mount ("tmpfs" , req .GetTargetPath (), "tmpfs" , []string {"size=1M" }); err != nil {
453+ return nil , status .Error (codes .Internal , err .Error ())
454+ }
455+
451456 options := []string {"bind" }
452457 if req .GetReadonly () {
453458 options = append (options , "remount" , "ro" )
@@ -606,14 +611,19 @@ func (ns *NodeServer) NodeUnpublishVolume(_ context.Context, req *csi.NodeUnpubl
606611 return nil , err
607612 }
608613
609- if err := mount .CleanupMountPoint (req .GetTargetPath (), ns .mounter , true ); err != nil {
610- if mounts , err := ns .mounter .GetMountRefs (req .GetTargetPath ()); err == nil && len (mounts ) == 0 {
611- return & csi.NodeUnpublishVolumeResponse {}, nil
614+ for {
615+ if err := ns .mounter .Unmount (req .GetTargetPath ()); err != nil {
616+ // keep unmounting whatever is on the folder until we can't
617+ break
612618 }
619+ }
620+
621+ if err := os .Remove (req .GetTargetPath ()); err != nil && ! errors .Is (err , os .ErrNotExist ) {
613622 return nil , status .Error (codes .Internal , err .Error ())
614623 }
615624
616625 return & csi.NodeUnpublishVolumeResponse {}, nil
626+
617627}
618628
619629func validateUnPublishVolumeRequest (req * csi.NodeUnpublishVolumeRequest ) error {
0 commit comments