-
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
libct/cg/v1: work around CPU quota period set failure #3090
libct/cg/v1: work around CPU quota period set failure #3090
Conversation
0763c54
to
4a951b1
Compare
A repro (which took me a while to write) fails as expected!
Adding the fix now. |
4d77f91
to
8dac477
Compare
Don't know how to create a transient scope from bash :( and this is required for centos 7's systemd. |
In theory, I should be able to use Another way is to use libcontainer and have a small go binary to do that. |
b284685
to
956b9a8
Compare
Trying it as I can't think of any better way right now. |
5e6f41f
to
c1ebddf
Compare
7c0ab98
to
8d2c6c3
Compare
8d2c6c3
to
395628b
Compare
Ughm; the backport (#3115) is already merged, and this one has no LGTMs :-\ @opencontainers/runc-maintainers PTAL 🙏🏻 |
@opencontainers/runc-maintainers PTAL 🙏🏻 |
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.
Didn't do a full review yet, but left a comment.
Also looks like the last commit is somewhat unrelated (could make sense separately)
contrib/cmd/sd-helper/helper.go
Outdated
// version will be populated by the Makefile, read from | ||
// VERSION file of the source code. | ||
var version = "" | ||
|
||
// gitCommit will be the hash that the binary was built from | ||
// and will be populated by the Makefile. | ||
var gitCommit = "" |
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.
Will this utility only be used for tests? Wondering if adding version information is a bit too much for that (or even using urfave/cli
for this).
Reason I'm looking at the version
variable, is also that if we want to switch to //go:embed
(#3163), the path to files to embed cannot traverse to parent directories (so //go:embed ../../VERSION
won't work) 😅
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 just copied this bit (as well as using urlfave/cli
) from recvtty
.
Let me try to drop both.
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.
Fixed, PTAL @thaJeztah
That's right, but it's harder to work on it if it's separate (since other commits in this PR also change the same file), and I don't want to forget about it. Let me try to rework it so the shellcheck fixes are separate. |
395628b
to
0ff9030
Compare
As reported in issue 3084, sometimes setting CPU quota period fails when a new period is lower and a parent cgroup has CPU quota limit set. This happens as in cgroup v1 the quota and the period can not be set together (this is fixed in v2), and since the period is being set first, new_limit = old_quota/new_period may be higher than the parent cgroup limit. The fix is to retry setting the period after the quota, to cover all possible scenarios. Add a test case to cover a regression caused by an earlier version of this patch (ignoring a failure of setting invalid period when quota is not set). Signed-off-by: Kir Kolyshkin <[email protected]>
Add a test case for an issue fixed by the previous commit. Unfortunately, this is somewhat complicated as there's no easy way to create a transient unit, so a binary, sd-helper, had to be added. On top of that, an ability to create a parent/pod cgroup is added to helpers.bash, which might be useful for future integration tests. Signed-off-by: Kir Kolyshkin <[email protected]>
0ff9030
to
6394457
Compare
Rebased on top of merged #3175, PTAL @thaJeztah |
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 fixes a real bug, and the backport to 1.0 was already merged and released in 1.0.2. @opencontainers/runc-maintainers PTAL |
For the reference, the same fix for crun: containers/crun#1188 |
This is based on (and currently includes) #3175.
I. As reported in issue #3084, sometimes setting CPU quota period fails
when a new period is lower and a parent cgroup has CPU quota limit set.
This happens as in cgroup v1 the quota and the period can not be set
together (this is fixed in v2), and since the period is being set first,
new_limit = old_quota/new_period
may be higher than the parentcgroup limit.
The fix is to retry setting the period after the quota, to cover all
possible scenarios.
Add a test case to cover a regression caused by an earlier version of
this patch (ignoring a failure of setting invalid period when quota is
not set).
Fixes: #3084
Closes: #2044
II. Add a test case for an issue fixed by the previous commit.
Unfortunately, this is somewhat complicated as there's no easy way to
create a transient unit, so a binary, sd-helper, had to be added. On top
of that, an ability to create a parent/pod cgroup is added to
helpers.bash, which might be useful for future integration tests.
History
1.0 backport: #3115