Skip to content

Fix cgroups cores detection#35815

Merged
alexey-milovidov merged 1 commit intomasterfrom
filimonov-patch-cgroups
Apr 1, 2022
Merged

Fix cgroups cores detection#35815
alexey-milovidov merged 1 commit intomasterfrom
filimonov-patch-cgroups

Conversation

@filimonov
Copy link
Copy Markdown
Contributor

@filimonov filimonov commented Mar 31, 2022

In Kubernetes shares are calculated from resources.requests.cpu, quota & period - from limits.

When you configure only requests without limits - the container still can use all the cores. So you see all the cores the system has.
(because of requests the pod just can't be scheduled on the node which have fewer CPUs)
So the effective CPU count is all the available cores if you don't have limits, or calculated from quota & period if you have the limits.

See the details of the problem https://kb.altinity.com/altinity-kb-setup-and-maintenance/cgroups_k8s/

Some info on cores calculation in cgroups: https://github.com/openjdk/jdk/blob/e07fd395bdc314867886a621ec76cf74a5f76b89/src/hotspot/os/linux/cgroupSubsystem_linux.cpp#L499-L512

Changelog category (leave one):

  • Bug Fix (user-visible misbehaviour in official stable or prestable release)

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Respect only quota & period from groups, ignore shares (which are not really limit the number of the cores which can be used)

/cc @JaySon-Huang @Felixoid

In Kubernetes shares are calculated from resources.requests.cpu, quota & period - from limits.

When you configure only requests without limits - the container still can use all the cores. So you see all the cores the system has.
(because of requests the pod just can't be scheduled on the node which have less cpus)
So the effective CPU count is all the available cores if you don't have limits, or calculated from quota & period if you have the limits.
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-bugfix Pull request with bugfix, not backported by default label Mar 31, 2022
@alexey-milovidov alexey-milovidov self-assigned this Apr 1, 2022
@alexey-milovidov alexey-milovidov merged commit ab3fc5e into master Apr 1, 2022
@alexey-milovidov alexey-milovidov deleted the filimonov-patch-cgroups branch April 1, 2022 00:02
alexey-milovidov added a commit that referenced this pull request Apr 3, 2022
Backport #35815 to 22.3: Fix cgroups cores detection
@Felixoid Felixoid added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jul 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants