-
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
fix systemd cpu quota for -1 #1805
fix systemd cpu quota for -1 #1805
Conversation
If the more appropriate change is to have Kubernetes send 0 whether cgroupfs or systemd driver, it would be good to get clarity from maintainers. |
it looks like passing 0 would be consistent across cgroupfs and systemd as any non-zero value results in writing out to cfs_quota_us, and since the default cfs_quota_us is -1, writing nothing would be fine. but if for example, we ever want to change from quota set to unset on an existing container, passing 0 would not induce a write with the cgroupfs driver, so maybe -1 is the right approach after all. |
Ok, hold on this until I make sure that -1 is consistently applied on create and update of existing cgroups. |
3dcd6de
to
3d5f4f3
Compare
/hold this for a moment while i do a few more tests in a kube context. |
// (integer percentage of CPU) internally. This means that if a fractional percent of | ||
// CPU is indicated by Resources.CpuQuota, we need to round up to the nearest | ||
// 10ms (1% of a second) such that child cgroups can set the cpu.cfs_quota_us they expect. | ||
cpuQuotaPerSecUSec := uint64(c.Resources.CpuQuota*1000000) / c.Resources.CpuPeriod |
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.
knew i messed something up, this shadows the var
Signed-off-by: Derek Carr <[email protected]>
3d5f4f3
to
b515963
Compare
ok, all set, sorry for spam. |
I verified this fix. With cpu-cfs-quota="true" limits were enforced at the pod and container level. When set to "false" the quota is not set (-1). |
Pointer to systemd code -- https://github.com/systemd/systemd/blob/master/src/core/cgroup.c#L522 |
if a caller passes -1 for cpu quota, no quota setting should be applied at all with systemd.
after #1651, passing -1 caused a side-effect of the value being converted to 10000 incorrectly.
this fixes an issue with the systemd cgroup driver in kubernetes when cfs quota is disabled.