fix cpu.cfs_quota_us changed when systemd daemon-reload using systemd.#1344
Conversation
46fe9f5 to
9f700d4
Compare
| if c.Resources.CpuQuota != 0 && c.Resources.CpuPeriod != 0 { | ||
| cpuQuota := c.Resources.CpuQuota * 100 / c.Resources.CpuPeriod | ||
| if cpuQuota == 0 { | ||
| return fmt.Errorf("cpu_quota divided by cpu_period must be greater than 0.01") |
There was a problem hiding this comment.
Why? Where does this requirement come from (if it's a kernel requirement -- which I assume it is -- then we generally don't error out for cases like this)?
There was a problem hiding this comment.
Because the systemd can not accept that the percentage(cpu_quota divided by cpu_period) is less than 0.01. For example, if the user let CpuQuota be 10 and CpuPeriod be 10000, the cpu.cfs_quota_us will be -1, not 10. So, I think it is necessary to warn the user that the percentage must be greater than 0.01.
There was a problem hiding this comment.
Can you provide a link to the systemd documentation which describes this option? I can't find it here. If it's an option added recently, you'll need to make your change backwards compatible with older systemd versions (by conditionally adding it like we do with Delegate for example).
There was a problem hiding this comment.
Actually, I did not find it from document. By observing, I found the percentage cannot be lower than 0.01. I found that if i set the percentage lower than 0.01, the cpu.cfs_quota_us will not be set as it should be set.
How about this idea? I delete this check and add docs about it to warn users.
9f700d4 to
46cab32
Compare
|
@cyphar I modified the code. Pls review it. |
6ad2da9 to
c44aec9
Compare
Signed-off-by: xuxinkun <xuxinkun@gmail.com>
|
@dqminh May you help review? |
This fix a conflict with systemd daemon-reload (see opencontainers/runc#1344) Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This fix a conflict with systemd daemon-reload (see opencontainers/runc#1344) Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
Automatic merge from submit-queue UPSTREAM: opencontainers/runc: 1344: fix cpu.cfs_quota_us changed when n systemd daemon-reload using systemd opencontainers/runc#1344 also see https://bugzilla.redhat.com/show_bug.cgi?id=1455071 @derekwaynecarr @runcom
Automatic merge from submit-queue UPSTREAM: opencontainers/runc: 1344: fix cpu.cfs_quota_us changed when systemd daemon-reload using systemd opencontainers/runc#1344 master PR: #16480 also see https://bugzilla.redhat.com/show_bug.cgi?id=1455071 @derekwaynecarr @runcom
Close moby/moby#30121