mirror of
https://github.com/kemko/nomad.git
synced 2026-01-08 11:25:41 +03:00
ci: fixup task runner chroot test
This PR is 2 fixes for the flaky TestTaskRunner_TaskEnv_Chroot test. And also the TestTaskRunner_Download_ChrootExec test. - Use TinyChroot to stop copying gigabytes of junk, which causes GHA to fail to create the environment in time. - Pre-create cgroups on V2 systems. Normally the cgroup directory is managed by the cpuset manager, but that is not active in taskrunner tests, so create it by hand in the test framework.
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
hclog "github.com/hashicorp/go-hclog"
|
||||
plugin "github.com/hashicorp/go-plugin"
|
||||
"github.com/hashicorp/nomad/ci"
|
||||
"github.com/hashicorp/nomad/client/allocdir"
|
||||
"github.com/hashicorp/nomad/client/config"
|
||||
"github.com/hashicorp/nomad/client/lib/cgutil"
|
||||
@@ -109,41 +110,6 @@ func (h *DriverHarness) cleanupCgroup() {
|
||||
}
|
||||
}
|
||||
|
||||
// tinyChroot is useful for testing, where we do not use anything other than
|
||||
// trivial /bin commands like sleep and sh.
|
||||
//
|
||||
// Note that you cannot chroot a symlink.
|
||||
var tinyChroot = map[string]string{
|
||||
// destination: /bin
|
||||
"/usr/bin/sleep": "/bin/sleep",
|
||||
"/usr/bin/dash": "/bin/sh",
|
||||
"/usr/bin/bash": "/bin/bash",
|
||||
"/usr/bin/cat": "/bin/cat",
|
||||
|
||||
// destination: /usr/bin
|
||||
"/usr/bin/stty": "/usr/bin/stty",
|
||||
"/usr/bin/head": "/usr/bin/head",
|
||||
"/usr/bin/mktemp": "/usr/bin/mktemp",
|
||||
"/usr/bin/echo": "/usr/bin/echo",
|
||||
"/usr/bin/touch": "/usr/bin/touch",
|
||||
"/usr/bin/stat": "/usr/bin/stat",
|
||||
|
||||
// destination: /etc/
|
||||
"/etc/ld.so.cache": "/etc/ld.so.cache",
|
||||
"/etc/ld.so.conf": "/etc/ld.so.conf",
|
||||
"/etc/ld.so.conf.d": "/etc/ld.so.conf.d",
|
||||
"/etc/passwd": "/etc/passwd",
|
||||
"/etc/resolv.conf": "/etc/resolv.conf",
|
||||
|
||||
// others
|
||||
"/lib": "/lib",
|
||||
"/lib32": "/lib32",
|
||||
"/lib64": "/lib64",
|
||||
"/usr/lib/jvm": "/usr/lib/jvm",
|
||||
"/run/resolvconf": "/run/resolvconf",
|
||||
"/run/systemd/resolve": "/run/systemd/resolve",
|
||||
}
|
||||
|
||||
// MkAllocDir creates a temporary directory and allocdir structure.
|
||||
// If enableLogs is set to true a logmon instance will be started to write logs
|
||||
// to the LogDir of the task
|
||||
@@ -165,7 +131,7 @@ func (h *DriverHarness) MkAllocDir(t *drivers.TaskConfig, enableLogs bool) func(
|
||||
|
||||
fsi := caps.FSIsolation
|
||||
h.logger.Trace("FS isolation", "fsi", fsi)
|
||||
require.NoError(h.t, taskDir.Build(fsi == drivers.FSIsolationChroot, tinyChroot))
|
||||
require.NoError(h.t, taskDir.Build(fsi == drivers.FSIsolationChroot, ci.TinyChroot))
|
||||
|
||||
task := &structs.Task{
|
||||
Name: t.Name,
|
||||
|
||||
Reference in New Issue
Block a user