Repository navigation
[release/8.0-staging] Be more liberal when detecting cgroup version - #99563
Closed
AustinWise wants to merge 1 commit into
Closed
AustinWise wants to merge 1 commit into
AustinWise wants to merge 1 commit into
Conversation
This changes the detection of cgroups to assume that if /sys/fs/cgroup is mounted and it is not cgroup v2, it is cgroup v1. While typically the file system type of /sys/fs/cgroup is TMPFS when cgroups v1 is being used, some emulated environments mount it as SYSFS.
AustinWise
requested review from
MichalStrehovsky,
lambdageek and
vargaz
as code owners
March 11, 2024 22:36
This was referenced Mar 12, 2024
Contributor
Author
|
As there are workarounds (use generation 2 execution environment, setting |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes Issue #99046
main PR #99508
Description
This changes the detection of cgroups to assume that if /sys/fs/cgroup is mounted and it is not cgroup v2, it is cgroup v1. While typically the file system type of /sys/fs/cgroup is TMPFS when cgroups v1 is being used, some emulated environments mount it as SYSFS.
Customer Impact
Excessive memory usage in some environments, leading to OOM. Customers can work around this issue by setting the
DOTNET_PROCESSOR_COUNTenvironment variable to override the number of processors.Regression
The check for TMPFS was introduced when cgroup2 supported was added in #34334 for .NET 5. It is likely that prior versions of .NET will detect the number of CPUs correctly, but I have not confirmed this.
Testing
I deployed a service to a Google Cloud Run generation 1 environment. I confirmed that the CPU count returned by
Environment.ProcessorCountreflected the CPU limit set for the container.Risk
While this change is small, it will cause execution to take a different path through a fair amount of string parsing code written in C. Looking at this string parsing code in cgroup.cpp, it appears to take care to be handle missing files and unexpected values. I also ran this code in debug mode in Cloud Run gen 1 to confirm no asserts were triggered.
Package authoring signed off?
IMPORTANT: If this change touches code that ships in a NuGet package, please make certain that you have added any necessary package authoring and gotten it explicitly reviewed.
I don't believe any of the code touched in this PR ships in a NuGet package. The C# code is included in
System.Diagnostics.Process, which is part of the shared framework.