Skip to content

Commit

Permalink
rebase: k8s.io/mount-utils/IsNotMountPoint() is deprecated
Browse files Browse the repository at this point in the history
IsNotMountPoint() is deprecated and Mounter.IsMountPoint() is
recommended to be used instead.

Reported-by: golangci/staticcheck
Signed-off-by: Niels de Vos <ndevos@redhat.com>
  • Loading branch information
nixpanic authored and mergify[bot] committed Aug 4, 2022
1 parent 10b2277 commit 83df1ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions internal/rbd/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ func (ns *NodeServer) NodeUnpublishVolume(
targetPath := req.GetTargetPath()
// considering kubelet make sure node operations like unpublish/unstage...etc can not be called
// at same time, an explicit locking at time of nodeunpublish is not required.
notMnt, err := mount.IsNotMountPoint(ns.Mounter, targetPath)
isMnt, err := ns.Mounter.IsMountPoint(targetPath)
if err != nil {
if os.IsNotExist(err) {
// targetPath has already been deleted
Expand All @@ -869,7 +869,7 @@ func (ns *NodeServer) NodeUnpublishVolume(

return nil, status.Error(codes.NotFound, err.Error())
}
if notMnt {
if !isMnt {
if err = os.RemoveAll(targetPath); err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
Expand Down Expand Up @@ -925,15 +925,15 @@ func (ns *NodeServer) NodeUnstageVolume(
stagingParentPath := req.GetStagingTargetPath()
stagingTargetPath := getStagingTargetPath(req)

notMnt, err := mount.IsNotMountPoint(ns.Mounter, stagingTargetPath)
isMnt, err := ns.Mounter.IsMountPoint(stagingTargetPath)
if err != nil {
if !os.IsNotExist(err) {
return nil, status.Error(codes.NotFound, err.Error())
}
// Continue on ENOENT errors as we may still have the image mapped
notMnt = true
isMnt = false
}
if !notMnt {
if isMnt {
// Unmounting the image
err = ns.Mounter.Unmount(stagingTargetPath)
if err != nil {
Expand Down Expand Up @@ -961,7 +961,7 @@ func (ns *NodeServer) NodeUnstageVolume(
log.UsefulLog(ctx, "failed to find image metadata: %v", err)
// It is an error if it was mounted, as we should have found the image metadata file with
// no errors
if !notMnt {
if isMnt {
return nil, status.Error(codes.Internal, err.Error())
}

Expand Down
4 changes: 2 additions & 2 deletions internal/rbd/rbd_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,12 +554,12 @@ func checkValidImageFeatures(imageFeatures string, ok bool) bool {
// isNotMountPoint checks whether MountPoint does not exists and
// also discards error indicating mountPoint exists.
func isNotMountPoint(mounter mount.Interface, stagingTargetPath string) (bool, error) {
isNotMnt, err := mount.IsNotMountPoint(mounter, stagingTargetPath)
isMnt, err := mounter.IsMountPoint(stagingTargetPath)
if os.IsNotExist(err) {
err = nil
}

return isNotMnt, err
return !isMnt, err
}

// isCephMgrSupported determines if the cluster has support for MGR based operation
Expand Down

0 comments on commit 83df1ea

Please sign in to comment.