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

Signed-off-by: Pawan <pawan@mayadata.io>
This commit is contained in:
Pawan 2020-12-15 00:02:25 +05:30 committed by Kiran Mova
parent 43553d6077
commit b42893ce47
2 changed files with 21 additions and 16 deletions

View file

@ -0,0 +1 @@
fixing idempotency check for the mount path

View file

@ -144,8 +144,6 @@ func verifyMountRequest(vol *apis.ZFSVolume, mountpath string) (bool, error) {
return false, status.Errorf(codes.Internal, "verifyMount: GetVolumePath failed %s", err.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* * This check is the famous *Wall Of North*
* It will not let the volume to be mounted * It will not let the volume to be mounted
@ -159,9 +157,15 @@ func verifyMountRequest(vol *apis.ZFSVolume, mountpath string) (bool, error) {
vol.Name, devicePath, err.Error()) vol.Name, devicePath, err.Error())
return false, status.Errorf(codes.Internal, "verifyMount: Getmounts failed %s", err.Error()) return false, status.Errorf(codes.Internal, "verifyMount: Getmounts failed %s", err.Error())
} else if len(currentMounts) >= 1 { } else if len(currentMounts) >= 1 {
if currentMounts[0] == mountpath { // if device is already mounted at the mount point, return successful
for _, mp := range currentMounts {
if mp == mountpath {
return true, nil 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( klog.Errorf(
"can not mount, volume:%s already mounted dev %s mounts: %v", "can not mount, volume:%s already mounted dev %s mounts: %v",
vol.Name, devicePath, currentMounts, vol.Name, devicePath, currentMounts,