Skip to content

Commit

Permalink
Merge pull request #1331 from huww98/fix-lint
Browse files Browse the repository at this point in the history
oss: use stat to detect mountpoint
  • Loading branch information
k8s-ci-robot authored Feb 26, 2025
2 parents f93986b + 35e9882 commit 1b9e51e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/mounter/proxy_mounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (m *ProxyMounter) MountWithSecrets(source, target, fstype string, options [
if err != nil {
return fmt.Errorf("failed to mount: %w", err)
}
notMnt, err := mountutils.IsNotMountPoint(m.Interface, target)
notMnt, err := m.IsLikelyNotMountPoint(target)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/oss/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
return nil, err
}
// check if already mounted
notMnt, err := isNotMountPoint(ns.rawMounter, targetPath, true)
notMnt, err := isNotMountPoint(ns.rawMounter, targetPath)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -192,7 +192,7 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
// When work as csi nodeserver, mount on the attach path under /run/fuse.ossfs and then perform the bind mount.
// check whether the attach path is mounted
attachPath := mounter.GetOssfsAttachPath(req.VolumeId)
notMnt, err = isNotMountPoint(ns.rawMounter, attachPath, false)
notMnt, err = isNotMountPoint(ns.rawMounter, attachPath)
if err != nil {
return nil, err
}
Expand Down
8 changes: 2 additions & 6 deletions pkg/oss/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,8 @@ func parseOtherOpts(otherOpts string) (mountOptions []string, err error) {
return mountOptions, nil
}

func isNotMountPoint(mounter mountutils.Interface, target string, expensive bool) (notMnt bool, err error) {
if expensive {
notMnt, err = mountutils.IsNotMountPoint(mounter, target)
} else {
notMnt, err = mounter.IsLikelyNotMountPoint(target)
}
func isNotMountPoint(mounter mountutils.Interface, target string) (notMnt bool, err error) {
notMnt, err = mounter.IsLikelyNotMountPoint(target)
if err != nil {
if os.IsNotExist(err) {
if err := os.MkdirAll(target, os.ModePerm); err != nil {
Expand Down

0 comments on commit 1b9e51e

Please sign in to comment.