aboutsummaryrefslogtreecommitdiff
path: root/pkg/driver/volume.go
diff options
context:
space:
mode:
authorChris Lu <chrislusf@users.noreply.github.com>2023-08-06 18:21:55 -0700
committerGitHub <noreply@github.com>2023-08-06 18:21:55 -0700
commit615c145190e7cb880bf2542d3ae9e750b28b9a89 (patch)
treee3c646e031c35b0299d58407994b10b5ed38a89a /pkg/driver/volume.go
parentd777b8750bb2dd33948988f4eec8813e6207a0cd (diff)
parenteca9cde95a899ab5645b00d8c0d547abd4bc7e8e (diff)
downloadseaweedfs-csi-driver-615c145190e7cb880bf2542d3ae9e750b28b9a89.tar.xz
seaweedfs-csi-driver-615c145190e7cb880bf2542d3ae9e750b28b9a89.zip
Merge pull request #131 from kvaster/refactor-1
Update dependencies
Diffstat (limited to 'pkg/driver/volume.go')
-rw-r--r--pkg/driver/volume.go18
1 files changed, 8 insertions, 10 deletions
diff --git a/pkg/driver/volume.go b/pkg/driver/volume.go
index ff303ea..5358700 100644
--- a/pkg/driver/volume.go
+++ b/pkg/driver/volume.go
@@ -9,7 +9,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/pb/mount_pb"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
- "k8s.io/utils/mount"
+ "k8s.io/mount-utils"
)
type Volume struct {
@@ -32,11 +32,11 @@ func NewVolume(volumeID string, mounter Mounter) *Volume {
func (vol *Volume) Stage(stagingTargetPath string) error {
// check whether it can be mounted
- if notMnt, err := checkMount(stagingTargetPath); err != nil {
+ if isMnt, err := checkMount(stagingTargetPath); err != nil {
return err
- } else if !notMnt {
+ } else if isMnt {
// try to unmount before mounting again
- _ = mount.New("").Unmount(stagingTargetPath)
+ _ = mountutil.Unmount(stagingTargetPath)
}
if u, err := vol.mounter.Mount(stagingTargetPath); err == nil {
@@ -49,9 +49,9 @@ func (vol *Volume) Stage(stagingTargetPath string) error {
func (vol *Volume) Publish(stagingTargetPath string, targetPath string, readOnly bool) error {
// check whether it can be mounted
- if notMnt, err := checkMount(targetPath); err != nil {
+ if isMnt, err := checkMount(targetPath); err != nil {
return err
- } else if !notMnt {
+ } else if isMnt {
// maybe already mounted?
return nil
}
@@ -62,8 +62,7 @@ func (vol *Volume) Publish(stagingTargetPath string, targetPath string, readOnly
mountOptions = append(mountOptions, "ro")
}
- mounter := mount.New("")
- if err := mounter.Mount(stagingTargetPath, targetPath, "", mountOptions); err != nil {
+ if err := mountutil.Mount(stagingTargetPath, targetPath, "", mountOptions); err != nil {
return err
}
@@ -89,8 +88,7 @@ func (vol *Volume) Expand(sizeByte int64) error {
func (vol *Volume) Unpublish(targetPath string) error {
// Try unmounting target path and deleting it.
- mounter := mount.New("")
- if err := mount.CleanupMountPoint(targetPath, mounter, true); err != nil {
+ if err := mount.CleanupMountPoint(targetPath, mountutil, true); err != nil {
return err
}