-
Notifications
You must be signed in to change notification settings - Fork 156
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
Support cgroup2 #44
Support cgroup2 #44
Conversation
CGroup-V2 has a different architecture which is unified. Since it is not yet supported in go, it makes sense to currently have the support. This commit adds the functionality to set GOMAXPROCS in cgroup2 enabled systems.
32bb5b7
to
0ae5491
Compare
Can someone at Uber provide information about if this project is still being supported? I'm considering to fork the project so it can be maintained. |
Thanks for the PR - we are looking for a reviewer internally. @prashantv and @akshayjshah have left the building... |
Happy to look at this PR, Alun, but I'd love to also get a stamp from someone who can speak authoritatively for Uber infra. |
Has anyone had a chance to review this yet? We've recently upgraded Flatcar and are running into cgroup V2 issues. If this is on track to be merged, we can just wait for it instead of forking and applying a patch. Thanks for good work here, everyone. 😄 |
You don't need to wait. Run this command at the root of your project where the go.mod file is located
Then switch your import to using this.
Everything will work. |
@alxn are you able to find an internal reviewer? |
cc @abhinav |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, @emadolsky! I'm not at Uber any more and didn't actually author this code, but it's nice to see this package still providing some value for the community.
I've left some comments on the PR (which hopefully the current Uber folks agree with). I'd wait for a review from one of the current maintainers before making any changes, though - in practice, they may not be accepting PRs for this package at all. In the meantime, it looks like you're the maintainer of the new automaxprocs
! 😸
internal/cgroups/cgroups.go
Outdated
} | ||
|
||
func cpuQuotaV2(cgroupv2MountPoint, cgroupv2CPUMax string) (float64, bool, error) { | ||
cpuMaxParams, err := os.Open(path.Join(cgroupv2MountPoint, cgroupv2CPUMax)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you should also include the cgroup-path from /proc/self/cgroup
, see https://man7.org/linux/man-pages/man7/cgroups.7.html
Codecov Report
@@ Coverage Diff @@
## master #44 +/- ##
==========================================
+ Coverage 92.07% 92.95% +0.88%
==========================================
Files 8 9 +1
Lines 164 213 +49
==========================================
+ Hits 151 198 +47
- Misses 10 11 +1
- Partials 3 4 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey folks, sorry for the delay. @mway and I will review this.
I've made an initial pass in terms of style and organization and made some updates.
In particular, I've moved the bulk of the v2 logic into separate files.
On top of that, I have limited knowledge of the underlying systems so I need some help understanding this:
Why is the mountpoint hard-coded to be /sys/fs/cgroup? As far as I can tell, mountinfo says "this is where cgroups2 is mounted", so should we not use whatever path is specified in mountinfo? Is it absolutely required for cgroups2 to mount to that path?
Naming wise, "give" and "want" are equally informative and much shorter.
This CGroups2 has the same interface as the CGroups object. This allows the logic in cpu_quota_linux to remain largely unchanged.
Turn the NewCGroupsForCurrentProcess and NewCGroups2ForCurrentProcess functions into function references so that we can replace them from tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made changes for readability, added more tests, and changed cpu_quota_linux so that the changes to the core logic are minimal.
This change LGTM now. I'm going to have someone else take a quick look over it, but it should be good to go otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
This change has not fixed the problem. I switched my code from "github.com/emadolsky/automaxprocs/maxprocs" to v1.5.0 and I am still getting that the CPU Quota is not defined. |
I noticed that in v1.5.0 https://github.com/uber-go/automaxprocs/blob/v1.5.0/internal/runtime/cpu_quota_linux.go#L35
In the emadolsky repo, it's working. I don't know enough to tell you why.
|
@abhinav - I also verify that the merged version doesn't work properly. |
I've add issue getting this working on k8s 1.26 (on google cloud), where apparently we use cgroup v2 ; I'm not positive that this is working. |
CGroup-V2 has a different architecture which is unified. Since it is not yet supported in go, it makes sense to currently have the
support. This commit adds the functionality to set GOMAXPROCS in cgroup2 enabled systems.
Also there were lint errors because of build annotation comments which are fixed in a separate commit.
This PR resolves #21.