Skip to content
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

driver: set cpuset when using cgroups v2 #252

Merged
merged 1 commit into from
Jun 12, 2023
Merged

driver: set cpuset when using cgroups v2 #252

merged 1 commit into from
Jun 12, 2023

Conversation

shoenig
Copy link
Member

@shoenig shoenig commented Jun 12, 2023

This PR makes it so that the Podman driver will now respect the task
config resources.cores value. When set, the task will be assigned the
specified number of CPU cores to be allowed to run on.

Note: unlike the docker/exec drivers, podman tasks will not be also allowed
to make use of the "shared" set of cpu cores (ones that have not yet been
reserved specifically for a task). Most likely that feature will be removed
in the near future (~Nomad 1.7) anyway.

Closes #160

This PR makes it so that the Podman driver will now respect the task
config resources.cores value. When set, the task will be assigned the
specified number of CPU cores to be allowed to run on.

Note: unlike the docker/exec drivers, podman tasks will not be also allowed
to make use of the "shared" set of cpu cores (ones that have not yet been
reserved specifically for a task). Most likely that feature will be removed
in the near future (~Nomad 1.7) anyway.
@shoenig
Copy link
Member Author

shoenig commented Jun 12, 2023

Spot check, just run a job with some cores using tasks and inspect their cgroup cpuset interface files.

basic job
job "sleep" {
  group "group" {
    count = 4

    task "sleep" {
      driver = "podman"

      config {
        image = "docker.io/bash:5"
        args  = ["sleep", "infinity"]
      }

      resources {
        cores  = 2
        memory = 64
      }
    }
  }
}

inspecting cpusets, each is assigned 2 cores

➜ cat /sys/fs/cgroup/nomad.slice/libpod*/container/cpuset.cpus.effective
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: /sys/fs/cgroup/nomad.slice/libpod-71531bfec2f731bd685dda3257c1ee258739abffff2f8133ad99518d86eb43bc.scope/container/cpuset.cpus.effective
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ 14-15
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: /sys/fs/cgroup/nomad.slice/libpod-9f884865bd52af3ef6474f0ca7d5ff9ae3798d58f48b795735ab2a302a61875b.scope/container/cpuset.cpus.effective
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ 16-17
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: /sys/fs/cgroup/nomad.slice/libpod-b1057260dbdff72fd119c1f5b98e783af2deef12a10f03426884b8c15143820c.scope/container/cpuset.cpus.effective
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ 10-11
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: /sys/fs/cgroup/nomad.slice/libpod-bc3f041ef6d8cc75e2a2c1de60006d36285d5f415c0815acdc2496f239358c6e.scope/container/cpuset.cpus.effective
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ 12-13
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

@shoenig shoenig marked this pull request as ready for review June 12, 2023 14:32
Copy link
Member

@jrasell jrasell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@shoenig shoenig merged commit 381cd93 into main Jun 12, 2023
@shoenig shoenig deleted the cg2-set-cpuset branch June 12, 2023 15:34
@shoenig shoenig added this to the v0.5.0 milestone Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for cpuset cgroups v2
2 participants