Skip to content

Conversation

@kolyshkin
Copy link
Contributor

@kolyshkin kolyshkin commented May 20, 2020

This fixes a few systemd cgroup bugs for both v1 and v2, and adds tests for systemd limit values (which uncover the bugs being fixed).

In particular, the bug fixes are:

  • allow to set TasksMax=infinity (aka pids.limit: -1) [v1 and v2]
  • set MemoryLow (aka memory.reservation) [v2 only]
  • update CPUQuotaPerSecUSec for some cases [v1 only]

The integration test improvements are:

  • simplify check_systemd_value usage
  • add missing checks for systemd's MemoryMax / MemoryLimit
  • add checks for systemd's MemoryLow and MemorySwapMax
  • add checks for systemd's TasksMax
  • add cgroupv1 systemd CPU checks (CPUShares and CPUQuotaPerSecUSec)
  • add a test that sets pids.limit=-1

Please see individual commits for details.

@kolyshkin
Copy link
Contributor Author

kolyshkin commented May 20, 2020

hmm, is there no CI for drafts? no, I was using the old branch

@kolyshkin kolyshkin marked this pull request as ready for review May 20, 2020 04:22
@kolyshkin kolyshkin marked this pull request as draft May 20, 2020 04:25
@kolyshkin kolyshkin force-pushed the systemd-v2-pids-max branch 7 times, most recently from 60c8635 to 546788c Compare May 20, 2020 08:53
@kolyshkin
Copy link
Contributor Author

This one is ready. There might be more similar work like that needed but this part is done.

@kolyshkin kolyshkin marked this pull request as ready for review May 20, 2020 16:13
@kolyshkin
Copy link
Contributor Author

@AkihiroSuda @mrunalp PTAL

@kolyshkin kolyshkin changed the title [WIP] fix some systemd limits Fix setting some systemd limits, add more tests May 20, 2020
@kolyshkin
Copy link
Contributor Author

@lifubang PTAL

kolyshkin added 6 commits May 20, 2020 13:15
...so it will be easier to write more tests

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
For some reason, this was not set before.

Test case is added by the next commit.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
1. add missing checks for systemd's MemoryMax / MemoryLimit.

2. add checks for systemd's MemoryLow and MemorySwapMax.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
1. do not allow to set quota without period or period without quota, as we
   won't be able to calculate new value for CPUQuotaPerSecUSec otherwise.

2. do not ignore setting quota to -1 when a period is not set.

3. update the test case accordingly.

Note that systemd value checks will be added in the next commit.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Currently, both systemd cgroup drivers (v1 and v2) only set
"TasksMax" unit property if the value > 0, so there is no
way to update the limit to -1 / unlimited / infinity / max.

Since systemd driver is backed by fs driver, and both fs and fs2
set the limit of -1 properly, it works, but systemd still has
the old value:

 # runc --systemd-cgroup update $CT --pids-limit 42
 # systemctl show runc-$CT.scope | grep TasksMax
 TasksMax=42
 # cat /sys/fs/cgroup/system.slice/runc-$CT.scope/pids.max
 42

 # ./runc --systemd-cgroup update $CT --pids-limit -1
 # systemctl show runc-$CT.scope | grep TasksMax=
 TasksMax=42
 # cat /sys/fs/cgroup/system.slice/runc-xx77.scope/pids.max
 max

Fix by changing the condition to allow -1 as a valid value.

NOTE other negative values are still being ignored by systemd drivers
(as it was done before). I am not sure whether this is correct, or
should we return an error.

A test case is added.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin kolyshkin force-pushed the systemd-v2-pids-max branch from 546788c to 5989736 Compare May 20, 2020 20:20
@AkihiroSuda
Copy link
Member

AkihiroSuda commented May 20, 2020

LGTM

Approved with PullApprove

1 similar comment
@mrunalp
Copy link
Contributor

mrunalp commented May 20, 2020

LGTM

Approved with PullApprove

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants