-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
libcontainer: set pids limit to max when set to 0 #4015
base: main
Are you sure you want to change the base?
Conversation
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.
Good catch!
aa86265
to
4eb2706
Compare
Some tests need to be fixed. |
3eb8ea5
to
78750bc
Compare
I can't see cs9 failure but I'm hoping it's a flake? regardless, comments addressed, PTAL |
I think maybe we need #3987 merged to fix this issue. |
Signed-off-by: Peter Hunt <pehunt@redhat.com>
78750bc
to
f12ea7b
Compare
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.
overall LGTM, thanks.
Left some small suggestions.
The current runc code treats PidsLimit value like this:
So, we have the "unset" case without using a pointer. The only issue is, we should properly convert runtime-spec representation into internal representation, essentially meaning, if spec value is I.e. something like this might be sufficient to fix the bug: --- a/libcontainer/specconv/spec_linux.go
+++ b/libcontainer/specconv/spec_linux.go
@@ -772,7 +772,13 @@ func CreateCgroupConfig(opts *CreateOpts, defaultDevs []*devices.Device) (*confi
c.Resources.CPUIdle = r.CPU.Idle
}
if r.Pids != nil {
- c.Resources.PidsLimit = r.Pids.Limit
+ if r.Pids.Limit > 0 {
+ c.Resources.PidsLimit = r.Pids.Limit
+ } else {
+ // Convert from runtime-spec (where a value <= 0 means "max")
+ // to internal (where -1 is "max", and 0 is "unset").
+ c.Resources.PidsLimit = -1
+ }
}
if r.BlockIO != nil {
if r.BlockIO.Weight != nil {
--- a/libcontainer/configs/cgroup_linux.go
+++ b/libcontainer/configs/cgroup_linux.go
@@ -90,7 +90,7 @@ type Resources struct {
// cgroup SCHED_IDLE
CPUIdle *int64 `json:"cpu_idle,omitempty"`
- // Process limit; set <= `0' to disable limit.
+ // Process limit; 0 is "unset", -1 is "max".
PidsLimit int64 `json:"pids_limit"`
// Specifies per cgroup weight, range is from 10 to 1000.
WDYT @lifubang @haircommander? I am more comfortable with a change like this merely because it is smaller and does not introduce a potential panic when dereferening a nil pointer. |
Yes, it is indeed a smaller change with your code. But I think |
That reminds me, changing I'll keep looking into it. |
I think it can't be defined as a breaking change, we don't break any result, this is just only a change of type, when they update to the new version of
There is a reason, if keep it as a raw type |
This is exactly what a breaking change is. Your code worked, you updated a dependency, and now it won't even compile. Yes, we've done it in the past and we'll do it again, but this should be justified.
Not necessarily. Current code treats |
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.
As outlined above, I don't like the PidsLimit change to be a pointer. See #4023 which fixes the issue reported without so much changes.
I am happy either way as long as the behavior when setting 0 to pids limit is well defined :) |
potentially fixes #4014