Skip to content

Commit 62c5fd9

Browse files
fix test
Signed-off-by: yaroslavborbat <[email protected]>
1 parent c6e7554 commit 62c5fd9

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

test/e2e/storage/drivers/in_tree.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
"time"
4444

4545
"github.com/onsi/ginkgo/v2"
46+
4647
v1 "k8s.io/api/core/v1"
4748
rbacv1 "k8s.io/api/rbac/v1"
4849
storagev1 "k8s.io/api/storage/v1"
@@ -1223,7 +1224,12 @@ func (l *localDriver) PrepareTest(ctx context.Context, f *framework.Framework) *
12231224
framework.ExpectNoError(err)
12241225

12251226
l.hostExec = utils.NewHostExec(f)
1226-
l.ltrMgr = utils.NewLocalResourceManager("local-driver", l.hostExec, "/tmp")
1227+
// It is recommended to mount /tmp with options noexec, nodev, nosuid.
1228+
// tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noexec,relatime,seclabel,inode64)
1229+
// This prevents scripts and binaries from being executed from the /tmp directory.
1230+
// This can cause errors like "Permission denied" when executing files from `/tmp`.
1231+
// To pass the test that verifies the execution of files on a volume, we use `/var` instead of `/tmp`.
1232+
l.ltrMgr = utils.NewLocalResourceManager("local-driver", l.hostExec, "/var")
12271233

12281234
// This can't be done in SkipUnsupportedTest because the test framework is not initialized yet
12291235
if l.volumeType == utils.LocalVolumeGCELocalSSD {

test/e2e/storage/utils/local.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"strings"
2828

2929
"github.com/onsi/ginkgo/v2"
30+
3031
v1 "k8s.io/api/core/v1"
3132
"k8s.io/apimachinery/pkg/util/uuid"
3233
"k8s.io/kubernetes/test/e2e/framework"
@@ -215,7 +216,7 @@ func (l *ltrMgr) cleanupLocalVolumeDirectory(ctx context.Context, ltr *LocalTest
215216
func (l *ltrMgr) setupLocalVolumeDirectoryLink(ctx context.Context, node *v1.Node, parameters map[string]string) *LocalTestResource {
216217
hostDir := l.getTestDir()
217218
hostDirBackend := hostDir + "-backend"
218-
cmd := fmt.Sprintf("mkdir %s && ln -s %s %s", hostDirBackend, hostDirBackend, hostDir)
219+
cmd := fmt.Sprintf("mkdir -p %s && ln -s %s %s", hostDirBackend, hostDirBackend, hostDir)
219220
err := l.hostExec.IssueCommand(ctx, cmd, node)
220221
framework.ExpectNoError(err)
221222
return &LocalTestResource{
@@ -235,7 +236,7 @@ func (l *ltrMgr) cleanupLocalVolumeDirectoryLink(ctx context.Context, ltr *Local
235236

236237
func (l *ltrMgr) setupLocalVolumeDirectoryBindMounted(ctx context.Context, node *v1.Node, parameters map[string]string) *LocalTestResource {
237238
hostDir := l.getTestDir()
238-
cmd := fmt.Sprintf("mkdir %s && mount --bind %s %s", hostDir, hostDir, hostDir)
239+
cmd := fmt.Sprintf("mkdir -p %s && mount --bind %s %s", hostDir, hostDir, hostDir)
239240
err := l.hostExec.IssueCommand(ctx, cmd, node)
240241
framework.ExpectNoError(err)
241242
return &LocalTestResource{
@@ -255,7 +256,7 @@ func (l *ltrMgr) cleanupLocalVolumeDirectoryBindMounted(ctx context.Context, ltr
255256
func (l *ltrMgr) setupLocalVolumeDirectoryLinkBindMounted(ctx context.Context, node *v1.Node, parameters map[string]string) *LocalTestResource {
256257
hostDir := l.getTestDir()
257258
hostDirBackend := hostDir + "-backend"
258-
cmd := fmt.Sprintf("mkdir %s && mount --bind %s %s && ln -s %s %s", hostDirBackend, hostDirBackend, hostDirBackend, hostDirBackend, hostDir)
259+
cmd := fmt.Sprintf("mkdir -p %s && mount --bind %s %s && ln -s %s %s", hostDirBackend, hostDirBackend, hostDirBackend, hostDirBackend, hostDir)
259260
err := l.hostExec.IssueCommand(ctx, cmd, node)
260261
framework.ExpectNoError(err)
261262
return &LocalTestResource{

0 commit comments

Comments
 (0)