libcontainer: set pids limit to max when set to 0#4015
libcontainer: set pids limit to max when set to 0#4015haircommander wants to merge 1 commit intoopencontainers:mainfrom
Conversation
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
lifubang
left a comment
There was a problem hiding this comment.
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 |
|
I am happy either way as long as the behavior when setting 0 to pids limit is well defined :) |
potentially fixes #4014