From 560dcf6648ec842d8c1f104a8d58f9dc1ed8f129 Mon Sep 17 00:00:00 2001 From: rohan2794 Date: Tue, 17 Sep 2024 12:39:50 +0530 Subject: [PATCH] create file over mounted path for github action kind cluster Signed-off-by: rohan2794 --- common/lvm/util.go | 23 +++++++++++++++++++---- common/zfs/util.go | 22 ++++++++++++++++++---- tools/e2e-agent/build.sh | 2 +- tools/e2e-agent/disk.go | 5 ++++- tools/e2e-agent/e2e-agent.yaml | 2 +- 5 files changed, 43 insertions(+), 11 deletions(-) diff --git a/common/lvm/util.go b/common/lvm/util.go index f823f06b..374b9d3b 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,28 @@ 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 + // Cluster setup on github runner will have worker name starts with kind- like kind-worker, kind-worker2 + // create disk image file at /mnt on host which will /host/host/mnt in e2e-agent container because + // on github runner one device is mounted + // and if worker name does not start kind- then create disk image file at /tmp directory of host + if strings.Contains(workerNodes[0], "kind-") { + imgDir = "/host/host/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 1b31ef3b..4879d5f9 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,27 @@ 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 + // Cluster setup on github runner will have worker name starts with kind- like kind-worker, kind-worker2 + // create disk image file at /mnt on host which will /host/host/mnt in e2e-agent container because + // on github runner one device is mounted + // and if worker name does not start kind- then create disk image file at /tmp directory of host + if strings.Contains(workerNodes[0], "kind-") { + imgDir = "/host/host/mnt" + } else { + imgDir = "/tmp" + } + loopDevice := e2e_agent.LoopDevice{ + Size: size, + ImgDir: imgDir, + } zfsNodeConfig = ZfsNodesDevicePoolConfig{ PoolName: poolName, diff --git a/tools/e2e-agent/build.sh b/tools/e2e-agent/build.sh index a0c7b63e..c39f82ea 100755 --- a/tools/e2e-agent/build.sh +++ b/tools/e2e-agent/build.sh @@ -9,7 +9,7 @@ # as long as we do not make breaking changes. set -e IMAGE="openebs/e2e-agent" -TAG="v3.0.2" +TAG="v3.0.3" registry="" tag_as_latest="" diff --git a/tools/e2e-agent/disk.go b/tools/e2e-agent/disk.go index 2daca779..6c26f0e3 100644 --- a/tools/e2e-agent/disk.go +++ b/tools/e2e-agent/disk.go @@ -41,7 +41,10 @@ func (disk *LoopDevice) createDiskImage() error { if err != nil { return fmt.Errorf("error truncating disk image. Error : %v", err) } - + err = f.Close() + if err != nil { + return fmt.Errorf("error closing disk image file %s. Error : %v", disk.ImageName, err) + } return nil } diff --git a/tools/e2e-agent/e2e-agent.yaml b/tools/e2e-agent/e2e-agent.yaml index 8758a7aa..8e715a0b 100644 --- a/tools/e2e-agent/e2e-agent.yaml +++ b/tools/e2e-agent/e2e-agent.yaml @@ -50,7 +50,7 @@ spec: securityContext: privileged: true allowPrivilegeEscalation: true - image: openebs/e2e-agent:v3.0.2 + image: openebs/e2e-agent:v3.0.3 imagePullPolicy: Always volumeMounts: - name: host-root