diff --git a/plugins/drivers/testutils/testing.go b/plugins/drivers/testutils/testing.go index 3aa411e5b1e3..f0f6c6713c2c 100644 --- a/plugins/drivers/testutils/testing.go +++ b/plugins/drivers/testutils/testing.go @@ -4,18 +4,17 @@ import ( "context" "fmt" "io/ioutil" + "os" "path/filepath" "runtime" "strings" "time" - "github.com/hashicorp/nomad/client/lib/cgutil" - "github.com/opencontainers/runc/libcontainer/cgroups/fs2" - hclog "github.com/hashicorp/go-hclog" plugin "github.com/hashicorp/go-plugin" "github.com/hashicorp/nomad/client/allocdir" "github.com/hashicorp/nomad/client/config" + "github.com/hashicorp/nomad/client/lib/cgutil" "github.com/hashicorp/nomad/client/logmon" "github.com/hashicorp/nomad/client/taskenv" "github.com/hashicorp/nomad/helper/testlog" @@ -76,7 +75,11 @@ func NewDriverHarness(t testing.T, d drivers.DriverPlugin) *DriverHarness { func (h *DriverHarness) setCgroup(allocID, task string) { if cgutil.UseV2 { h.cgroup = filepath.Join(cgutil.CgroupRoot, "testing.slice", cgutil.CgroupScope(allocID, task)) - _ = fs2.CreateCgroupPath(h.cgroup, nil) + f, err := os.Create(h.cgroup) + if err != nil { + panic(err) + } + defer f.Close() } } @@ -88,8 +91,10 @@ func (h *DriverHarness) Kill() { func (h *DriverHarness) cleanupCgroup() { if cgutil.UseV2 { - mgr, _ := fs2.NewManager(nil, h.cgroup, false) - _ = mgr.Destroy() + err := os.Remove(h.cgroup) + if err != nil { + panic(err) + } } }