diff --git a/common/lvm/util.go b/common/lvm/util.go index f823f06..3204207 100644 --- a/common/lvm/util.go +++ b/common/lvm/util.go @@ -2,6 +2,7 @@ package lvm import ( "fmt" + "strings" "github.com/openebs/openebs-e2e/common" "github.com/openebs/openebs-e2e/common/e2e_agent" @@ -132,14 +133,24 @@ func (lvmNodesDevicePvVgConfig *LvmNodesDevicePvVgConfig) ConfigureLvmNodesWithD func SetupLvmNodes(vgName string, size int64) (LvmNodesDevicePvVgConfig, error) { var lvmNodeConfig LvmNodesDevicePvVgConfig - loopDevice := e2e_agent.LoopDevice{ - Size: size, - ImgDir: "/tmp", - } workerNodes, err := ListLvmNode(common.NSOpenEBS()) if err != nil { return lvmNodeConfig, fmt.Errorf("failed to list lvm worker nodes, error: %v", err) } + if len(workerNodes) == 0 { + return lvmNodeConfig, fmt.Errorf("lvm worker nodes not found") + } + var imgDir string + if strings.Contains(workerNodes[0], "kind-") { + imgDir = "/mnt" + } else { + imgDir = "/tmp" + } + + loopDevice := e2e_agent.LoopDevice{ + Size: size, + ImgDir: imgDir, + } lvmNodeConfig = LvmNodesDevicePvVgConfig{ VgName: vgName, diff --git a/common/zfs/util.go b/common/zfs/util.go index 1b31ef3..21d8274 100644 --- a/common/zfs/util.go +++ b/common/zfs/util.go @@ -2,6 +2,7 @@ package zfs import ( "fmt" + "strings" "github.com/openebs/openebs-e2e/common" "github.com/openebs/openebs-e2e/common/e2e_agent" @@ -103,14 +104,23 @@ func (zfsDevicePoolConfig *ZfsNodesDevicePoolConfig) ConfigureZfsNodesWithDevice func SetupZfsNodes(poolName string, size int64) (ZfsNodesDevicePoolConfig, error) { var zfsNodeConfig ZfsNodesDevicePoolConfig - loopDevice := e2e_agent.LoopDevice{ - Size: size, - ImgDir: "/tmp", - } workerNodes, err := ListZfsNode(common.NSOpenEBS()) if err != nil { return zfsNodeConfig, fmt.Errorf("failed to list zfs worker nodes, error: %v", err) } + if len(workerNodes) == 0 { + return zfsNodeConfig, fmt.Errorf("zfs worker nodes not found") + } + var imgDir string + if strings.Contains(workerNodes[0], "kind-") { + imgDir = "/mnt" + } else { + imgDir = "/tmp" + } + loopDevice := e2e_agent.LoopDevice{ + Size: size, + ImgDir: imgDir, + } zfsNodeConfig = ZfsNodesDevicePoolConfig{ PoolName: poolName,