Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mount): fixing idempotency check for the mount path #260

Merged
merged 2 commits into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
id: buildx
uses: docker/setup-buildx-action@v1
with:
version: latest
version: v0.4.2

- name: Login to Docker Hub
uses: docker/login-action@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
id: buildx
uses: docker/setup-buildx-action@v1
with:
version: latest
version: v0.4.2

- name: Build Image
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
id: buildx
uses: docker/setup-buildx-action@v1
with:
version: latest
version: v0.4.2

- name: Login to Docker Hub
uses: docker/login-action@v1
Expand Down
1 change: 1 addition & 0 deletions changelogs/unreleased/260-pawanpraka1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fixing idempotency check for the mount path
36 changes: 20 additions & 16 deletions pkg/zfs/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,24 +144,28 @@ func verifyMountRequest(vol *apis.ZFSVolume, mountpath string) (bool, error) {
return false, status.Errorf(codes.Internal, "verifyMount: GetVolumePath failed %s", err.Error())
}

// if it is not a shared volume, then make sure it is not mounted to more than one path
if vol.Spec.Shared != "yes" {
/*
* This check is the famous *Wall Of North*
* It will not let the volume to be mounted
* at more than two places. The volume should
* be unmounted before proceeding to the mount
* operation.
*/
currentMounts, err := mnt.GetMounts(devicePath)
if err != nil {
klog.Errorf("can not get mounts for volume:%s dev %s err: %v",
vol.Name, devicePath, err.Error())
return false, status.Errorf(codes.Internal, "verifyMount: Getmounts failed %s", err.Error())
} else if len(currentMounts) >= 1 {
if currentMounts[0] == mountpath {
/*
* This check is the famous *Wall Of North*
* It will not let the volume to be mounted
* at more than two places. The volume should
* be unmounted before proceeding to the mount
* operation.
*/
currentMounts, err := mnt.GetMounts(devicePath)
if err != nil {
klog.Errorf("can not get mounts for volume:%s dev %s err: %v",
vol.Name, devicePath, err.Error())
return false, status.Errorf(codes.Internal, "verifyMount: Getmounts failed %s", err.Error())
} else if len(currentMounts) >= 1 {
// if device is already mounted at the mount point, return successful
for _, mp := range currentMounts {
kmova marked this conversation as resolved.
Show resolved Hide resolved
if mp == mountpath {
return true, nil
}
}

// if it is not a shared volume, then it should not mounted to more than one path
if vol.Spec.Shared != "yes" {
klog.Errorf(
"can not mount, volume:%s already mounted dev %s mounts: %v",
vol.Name, devicePath, currentMounts,
Expand Down