-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers/raw_exec: enable setting cgroup override values #20481
Conversation
cbbc7b8
to
f69b8d0
Compare
Example (cgroups v1):job "sleep" {
group "group" {
task "task" {
driver = "raw_exec"
config {
command = "sleep"
args = ["infinity"]
cgroup_v1_override = {
"pids" : "custom/app",
"cpuset" : "custom/app",
}
}
}
}
} Ensure our custom cgroup under the
Ensure our custom cgroup under the
Run job. Our custom cgroups are in use.
|
f69b8d0
to
546c7cb
Compare
Example (cgroups v2)job "sleep" {
group "group" {
task "task" {
driver = "raw_exec"
config {
command = "sleep"
args = ["infinity"]
cgroup_v2_override = "custom.slice/app.scope"
}
}
}
} Ensure our custom unified cgroup exists.
Run job. Ensure our custom cgroup is in use.
|
546c7cb
to
0bde666
Compare
This PR enables configuration of cgroup override values on the `raw_exec` task driver. WARNING: setting cgroup override values eliminates any gauruntee Nomad can make about resource availability for *any* task on the client node. For cgroup v2 systems, set a single unified cgroup path using `cgroup_v2_override`. The path may be either absolute or relative to the cgroup root. config { cgroup_v2_override = "custom.slice/app.scope" } or config { cgroup_v2_override = "/sys/fs/cgroup/custom.slice/app.scope" } For cgroup v1 systems, set a per-controller path for each controller using `cgroup_v1_override`. The path(s) may be either absolute or relative to the controller root. config { cgroup_v1_override = { "pids": "custom/app", "cpuset": "custom/app", } } or config { cgroup_v1_override = { "pids": "/sys/fs/cgroup/pids/custom/app", "cpuset": "/sys/fs/cgroup/cpuset/custom/app", } }
0bde666
to
c8f273c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to confirm: this doesn't appear to create cgroups if they don't exist or remove cgroups on text exit, correct?
for controller, path := range e.command.OverrideCgroupV1 { | ||
absPath := cgroupslib.CustomPathCG1(controller, path) | ||
ed := cgroupslib.OpenPath(absPath) | ||
_ = ed.Write("cgroup.procs", strconv.Itoa(pid)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need to check the return value here or risk a task running without being added to its intended cgroup?
Making sure task does not start if cgroup override does not exist Cgroups v1
Cgroups v2
|
Making sure config allows for only one of v1 or v2 override being set config {
command = "sleep"
args = ["infinity"]
cgroup_v1_override = {
"pids": "custom/app",
"cpuset": "custom/app",
}
cgroup_v2_override = "custom.slice/app.scope"
}
|
@@ -222,10 +239,11 @@ func (e *UniversalExecutor) configureCG1(cgroup string, command *ExecCommand) { | |||
ed = cgroupslib.OpenPath(cpusetPath) | |||
_ = ed.Write("cpuset.cpus", cpuSet) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safe to ignore this error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Historically we had to ignore these errors because people keep running Nomad as non-root or on systems where only some of the cgroup controllers are enabled. But they still want raw_exec to Just Work for them.
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
This PR enables configuration of cgroup override values on the
raw_exec
task driver. WARNING: setting cgroup override values eliminates any
guarantee Nomad can make about resource availability for any task on
the client node.
For cgroup v2 systems, set a single unified cgroup path using
cgroup_v2_override
.The path may be either absolute or relative to the cgroup root.
or
For cgroup v1 systems, set a per-controller path for each controller using
cgroup_v1_override
. The path(s) may be either absolute or relative tothe controller root.
or