Some refactoring on PidsLimit#38793
Conversation
Codecov Report
@@ Coverage Diff @@
## master #38793 +/- ##
==========================================
- Coverage 36.47% 36.46% -0.01%
==========================================
Files 613 613
Lines 45814 45845 +31
==========================================
+ Hits 16709 16716 +7
- Misses 26823 26848 +25
+ Partials 2282 2281 -1 |
There was a problem hiding this comment.
Was in doubt if I should change this to a non-pointer to make it easier to use (and if no limit is needed, don't pass WithPidsLimit())
There was a problem hiding this comment.
I can see both ways here. In the end I think making a pointer is simpler than dealing with filtering options... e.g.
opts := []ConfigOpts{WithFoo,WithBar}
if hasLimit {
opts = append(opts, WithPidsLimit(limit))
}
container.Run(..., opts...)There was a problem hiding this comment.
seems like a valid choice. we're not doing anything with the network here.
daemon/daemon_unix.go
Outdated
There was a problem hiding this comment.
nice cleanup of the comment.
- Don't set `PidsLimit` when creating a container and no limit was set (or the limit was set to "unlimited") - Don't set `PidsLimit` if the host does not have pids-limit support (previously "unlimited" was set). - Do not generate a warning if the host does not have pids-limit support, but pids-limit was set to unlimited (having no limit set, or the limit set to "unlimited" is equivalent, so no warning is nescessary in that case). - When updating a container, convert `0`, and `-1` to "unlimited" (`0`). Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Create a new container for each subtest, so that individual subtests are self-contained, and there's no need to execute them in the exact order, or resetting the container in between. This makes the test slower (6.54s vs 3.43s), but reduced the difference by using `network=host`, which made a substantial difference (without `network=host`, the test took more than twice as long: 13.96s). Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
379f150 to
1101568
Compare
|
rebased; PTAL |
cpuguy83
left a comment
There was a problem hiding this comment.
Oy, the more I look at this the more I'm worried about the change we made to support updates for pids limit.
This change LGTM, though.
| // WithPidsLimit sets the container's "pids-limit | ||
| func WithPidsLimit(limit *int64) func(*TestContainerConfig) { | ||
| return func(c *TestContainerConfig) { | ||
| if c.HostConfig == nil { |
There was a problem hiding this comment.
nit: I don't think this is needed at this point.
There was a problem hiding this comment.
hm.. possibly; I might have run into a situation where it was nil, but perhaps that was when I was working on the test. Don't think it hurts to have it 😅
I was trying to make the flow more consistent (some attempts in #38676). I think one of the problems we have currently is that in many cases, the ( I've been following some of the code-paths, and validation of values is interweaved throughout the codebase; here's some notes I was taking; I think what would be nice if we would handle the API "conversion" in the API code (where possible), so that the config as stored on disk could more easily be converted to an OCI-spec without having to handle those conversions (again), and an "update" would be more of a "reconciliation". Validation might become easier then as well. Probably that would be problematic for upgrade scenarios (configs created by older versions of the daemon), and there's likely many things I didn't consider. Also; I keep looking at our tests, and thinking that the client we use in our tests has a much nicer interface than the API client (with the functional arguments) (disclaimer: I've become a bit of a fan of those 😅) |
MHBauer
left a comment
There was a problem hiding this comment.
I thought I had decoupled the API, but it looks like it's back to sharing structs.
LGTM
Some follow-ups to #38791
(first commit is #38791)Normalize values for pids-limit
PidsLimitwhen creating a container and no limit was set (or the limit was set to "unlimited")PidsLimitif the host does not have pids-limit support (previously "unlimited" was set).0, and-1to "unlimited" (0).Update TestUpdatePidsLimit to be more atomic
Create a new container for each subtest, so that individual subtests are self-contained, and there's no need to execute them in the exact order, or resetting the container in between.
This makes the test slower (6.54s vs 3.43s), but reduced the difference by using
network=host, which made a substantial difference (withoutnetwork=host, the test took more than twice as long: 13.96s).