From 62c5fd9438fc1a204e2e41bd243379c46b92c0ca Mon Sep 17 00:00:00 2001 From: yaroslavborbat Date: Tue, 1 Oct 2024 10:36:00 +0300 Subject: [PATCH] fix test Signed-off-by: yaroslavborbat --- test/e2e/storage/drivers/in_tree.go | 8 +++++++- test/e2e/storage/utils/local.go | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/test/e2e/storage/drivers/in_tree.go b/test/e2e/storage/drivers/in_tree.go index 58ec455c67b..8e6ef01d8f0 100644 --- a/test/e2e/storage/drivers/in_tree.go +++ b/test/e2e/storage/drivers/in_tree.go @@ -43,6 +43,7 @@ import ( "time" "github.com/onsi/ginkgo/v2" + v1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" storagev1 "k8s.io/api/storage/v1" @@ -1223,7 +1224,12 @@ func (l *localDriver) PrepareTest(ctx context.Context, f *framework.Framework) * framework.ExpectNoError(err) l.hostExec = utils.NewHostExec(f) - l.ltrMgr = utils.NewLocalResourceManager("local-driver", l.hostExec, "/tmp") + // It is recommended to mount /tmp with options noexec, nodev, nosuid. + // tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noexec,relatime,seclabel,inode64) + // This prevents scripts and binaries from being executed from the /tmp directory. + // This can cause errors like "Permission denied" when executing files from `/tmp`. + // To pass the test that verifies the execution of files on a volume, we use `/var` instead of `/tmp`. + l.ltrMgr = utils.NewLocalResourceManager("local-driver", l.hostExec, "/var") // This can't be done in SkipUnsupportedTest because the test framework is not initialized yet if l.volumeType == utils.LocalVolumeGCELocalSSD { diff --git a/test/e2e/storage/utils/local.go b/test/e2e/storage/utils/local.go index df96eac124e..1dccee34625 100644 --- a/test/e2e/storage/utils/local.go +++ b/test/e2e/storage/utils/local.go @@ -27,6 +27,7 @@ import ( "strings" "github.com/onsi/ginkgo/v2" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/uuid" "k8s.io/kubernetes/test/e2e/framework" @@ -215,7 +216,7 @@ func (l *ltrMgr) cleanupLocalVolumeDirectory(ctx context.Context, ltr *LocalTest func (l *ltrMgr) setupLocalVolumeDirectoryLink(ctx context.Context, node *v1.Node, parameters map[string]string) *LocalTestResource { hostDir := l.getTestDir() hostDirBackend := hostDir + "-backend" - cmd := fmt.Sprintf("mkdir %s && ln -s %s %s", hostDirBackend, hostDirBackend, hostDir) + cmd := fmt.Sprintf("mkdir -p %s && ln -s %s %s", hostDirBackend, hostDirBackend, hostDir) err := l.hostExec.IssueCommand(ctx, cmd, node) framework.ExpectNoError(err) return &LocalTestResource{ @@ -235,7 +236,7 @@ func (l *ltrMgr) cleanupLocalVolumeDirectoryLink(ctx context.Context, ltr *Local func (l *ltrMgr) setupLocalVolumeDirectoryBindMounted(ctx context.Context, node *v1.Node, parameters map[string]string) *LocalTestResource { hostDir := l.getTestDir() - cmd := fmt.Sprintf("mkdir %s && mount --bind %s %s", hostDir, hostDir, hostDir) + cmd := fmt.Sprintf("mkdir -p %s && mount --bind %s %s", hostDir, hostDir, hostDir) err := l.hostExec.IssueCommand(ctx, cmd, node) framework.ExpectNoError(err) return &LocalTestResource{ @@ -255,7 +256,7 @@ func (l *ltrMgr) cleanupLocalVolumeDirectoryBindMounted(ctx context.Context, ltr func (l *ltrMgr) setupLocalVolumeDirectoryLinkBindMounted(ctx context.Context, node *v1.Node, parameters map[string]string) *LocalTestResource { hostDir := l.getTestDir() hostDirBackend := hostDir + "-backend" - cmd := fmt.Sprintf("mkdir %s && mount --bind %s %s && ln -s %s %s", hostDirBackend, hostDirBackend, hostDirBackend, hostDirBackend, hostDir) + cmd := fmt.Sprintf("mkdir -p %s && mount --bind %s %s && ln -s %s %s", hostDirBackend, hostDirBackend, hostDirBackend, hostDirBackend, hostDir) err := l.hostExec.IssueCommand(ctx, cmd, node) framework.ExpectNoError(err) return &LocalTestResource{