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

cgroupslib: allow initial controller check with delegated cgroups #23803

Merged
merged 1 commit into from
Aug 14, 2024

Conversation

tgross
Copy link
Member

@tgross tgross commented Aug 13, 2024

During Nomad client initialization with cgroups v2, we assert that the required cgroup controllers are available in the root cgroup.subtree_control file by idempotently writing to the file. But if Nomad is running with delegated cgroups, this will fail file permissions checks even if the subtree control file already has the controllers we need.

Update the initialization to first check if the controllers are missing before attempting to write to them. This allows cgroup delegation so long as the cluster administrator has pre-created a Nomad owned cgroups tree and set the Delegate option in a systemd override. If not, initialization fails in the existing way.

Although this is one small step along the way to supporting a rootless Nomad client, running Nomad as non-root is still unsupported. I've intentionally not documented setting up cgroup delegation in this PR, as this PR is insufficient by itself to have a secure and properly-working rootless Nomad client.

Ref: #18211
Ref: #13669
Ref: https://hashicorp.atlassian.net/browse/NET-10652
Ref: https://hashicorp.atlassian.net/browse/NET-10668

@tgross tgross changed the title cgroupslib: allow cgroups delegation during initialization cgroupslib: allow initial controller check with delegated cgroups Aug 13, 2024
@tgross tgross added this to the 1.8.x milestone Aug 13, 2024
@tgross tgross added the backport/1.8.x backport to 1.8.x release line label Aug 13, 2024
@tgross tgross marked this pull request as ready for review August 14, 2024 18:42
@tgross tgross added the theme/rootless Run Nomad Client without root label Aug 14, 2024
@tgross tgross modified the milestones: 1.8.x, 1.8.4 Aug 14, 2024
@tgross tgross mentioned this pull request Aug 14, 2024
Copy link
Member

@shoenig shoenig left a comment

Choose a reason for hiding this comment

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

LGTM!

During Nomad client initialization with cgroups v2, we assert that the required
cgroup controllers are available in the root `cgroup.subtree_control` file by
idempotently writing to the file. But if Nomad is running with delegated
cgroups, this will fail file permissions checks even if the subtree control file
already has the controllers we need.

Update the initialization to first check if the controllers are missing before
attempting to write to them. This allows cgroup delegation so long as the
cluster administrator has pre-created a Nomad owned cgroups tree and set the
`Delegate` option in a systemd override. If not, initialization fails in the
existing way.

Although this is one small step along the way to supporting a rootless Nomad
client, running Nomad as non-root is still unsupported. I've intentionally not
documented setting up cgroup delegation in this PR, as this PR is insufficient
by itself to have a secure and properly-working rootless Nomad client.

Ref: #18211
Ref: #13669
@tgross tgross merged commit 682c8c0 into main Aug 14, 2024
19 checks passed
@tgross tgross deleted the cgroups-delegation branch August 14, 2024 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.8.x backport to 1.8.x release line theme/cgroups cgroups issues theme/rootless Run Nomad Client without root type/enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants