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

client: refactor cpuset manager initialization #14230

Merged
merged 1 commit into from
Aug 25, 2022
Merged

Conversation

shoenig
Copy link
Member

@shoenig shoenig commented Aug 23, 2022

This PR refactors the code path in Client startup for setting up the cpuset
cgroup manager (non-linux systems not affected).

Before, there was a logic bug where we would try to read the cpuset.cpus.effective
cgroup interface file before ensuring nomad's parent cgroup existed. Therefore on first run that
file would not exist, and the list of usable cpus would be empty. Tasks started
thereafter would not have a value set for their cpuset.cpus file.

The refactoring fixes some hard to parse init code. Instead we now bootstrap
each cpuset manager type (v1/v2) within its own constructor. If something goes
awry during bootstrap (e.g. cgroups not enabled), the constructor returns the
noop implementation and logs a warning.

Fixes #14229

Only 1.3.x and higher, when cgroup v2 support was added

@shoenig shoenig added this to the 1.3.4 milestone Aug 23, 2022
@shoenig shoenig marked this pull request as ready for review August 23, 2022 18:49
@shoenig shoenig added backport/1.2.x backport to 1.1.x release line backport/1.3.x backport to 1.3.x release line and removed backport/1.2.x backport to 1.1.x release line labels Aug 23, 2022
Copy link
Contributor

@lgfa29 lgfa29 left a comment

Choose a reason for hiding this comment

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

Changes LGTM. Do you think it needs a CHANGELOG entry?

@shoenig
Copy link
Member Author

shoenig commented Aug 25, 2022

a CHANGELOG entry?

ahh I dunno how I keep forgetting these! I'll add one

This PR refactors the code path in Client startup for setting up the cpuset
cgroup manager (non-linux systems not affected).

Before, there was a logic bug where we would try to read the cpuset.cpus.effective
cgroup interface file before ensuring nomad's parent cgroup existed. Therefor that
file would not exist, and the list of useable cpus would be empty. Tasks started
thereafter would not have a value set for their cpuset.cpus.

The refactoring fixes some less than ideal coding style. Instead we now bootstrap
each cpuset manager type (v1/v2) within its own constructor. If something goes
awry during bootstrap (e.g. cgroups not enabled), the constructor returns the
noop implementation and logs a warning.

Fixes #14229
lgfa29 pushed a commit that referenced this pull request Aug 25, 2022
client: refactor cpuset manager initialization
lgfa29 pushed a commit that referenced this pull request Aug 25, 2022
client: refactor cpuset manager initialization
lgfa29 pushed a commit that referenced this pull request Aug 25, 2022
client: refactor cpuset manager initialization

Co-authored-by: Seth Hoenig <seth.a.hoenig@gmail.com>
@github-actions
Copy link

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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/1.3.x backport to 1.3.x release line
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix cpuset cgroup manager initialization
2 participants