mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
* client: refactor cpuset partitioning This PR updates the way Nomad client manages the split between tasks that make use of resources.cpus vs. resources.cores. Previously, each task was explicitly assigned which CPU cores they were able to run on. Every time a task was started or destroyed, all other tasks' cpusets would need to be updated. This was inefficient and would crush the Linux kernel when a client would try to run ~400 or so tasks. Now, we make use of cgroup heirarchy and cpuset inheritence to efficiently manage cpusets. * cr: tweaks for feedback
26 lines
724 B
Go
26 lines
724 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
//go:build linux
|
|
|
|
package testutils
|
|
|
|
import (
|
|
"github.com/hashicorp/nomad/client/lib/cgroupslib"
|
|
"github.com/shoenig/test/must"
|
|
)
|
|
|
|
// MakeTaskCgroup creates the cgroup that the task driver might assume already
|
|
// exists, since Nomad client creates them. Why do we write tests that directly
|
|
// invoke task drivers without any context of the Nomad client? Who knows.
|
|
func (h *DriverHarness) MakeTaskCgroup(allocID, taskName string) {
|
|
f := cgroupslib.Factory(allocID, taskName, false)
|
|
must.NoError(h.t, f.Setup())
|
|
|
|
// ensure child procs are dead and remove the cgroup when the test is done
|
|
h.t.Cleanup(func() {
|
|
_ = f.Kill()
|
|
_ = f.Teardown()
|
|
})
|
|
}
|