Skip to content

Commit 5165590

Browse files
committed
1. Make kubelet default to 10ms for CPU quota if limit < 10m for
backwards compat. 2. Update documentation to reflect minimum CPU limits. Signed-off-by: Vishnu kannan <vishnuk@google.com>
1 parent 6cd8e5c commit 5165590

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

docs/proposals/resource-qos.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ For each resource, containers can specify a resource request and limit, 0 <= req
6161
### Compressible Resource Guarantees
6262

6363
- For now, we are only supporting CPU.
64+
- Minimum CPU limit is 10 milli cores (`10m`). This a limitation of the Linux kernel.
6465
- Containers are guaranteed to get the amount of CPU they request, they may or may not get additional CPU time (depending on the other jobs running).
6566
- Excess CPU resources will be distributed based on the amount of CPU requested. For example, suppose container A requests for 60% of the CPU, and container B requests for 30% of the CPU. Suppose that both containers are trying to use as much CPU as they can. Then the extra 10% of CPU will be distributed to A and B in a 2:1 ratio (implementation discussed in later sections).
6667
- Containers will be throttled if they exceed their limit. If limit is unspecified, then the containers can use excess CPU when available.

pkg/kubelet/dockertools/docker.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ const (
5050
milliCPUToCPU = 1000
5151

5252
// 100000 is equivalent to 100ms
53-
quotaPeriod = 100000
53+
quotaPeriod = 100000
54+
minQuotaPerod = 1000
5455
)
5556

5657
// DockerInterface is an abstract interface for testability. It abstracts the interface of docker.Client.
@@ -317,6 +318,11 @@ func milliCPUToQuota(milliCPU int64) (quota int64, period int64) {
317318
// we then convert your milliCPU to a value normalized over a period
318319
quota = (milliCPU * quotaPeriod) / milliCPUToCPU
319320

321+
// quota needs to be a minimum of 1ms.
322+
if quota < minQuotaPerod {
323+
quota = minQuotaPerod
324+
}
325+
320326
return
321327
}
322328

pkg/kubelet/dockertools/docker_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,21 @@ func TestMilliCPUToQuota(t *testing.T) {
839839
quota: int64(0),
840840
period: int64(0),
841841
},
842+
{
843+
input: int64(5),
844+
quota: int64(1000),
845+
period: int64(100000),
846+
},
847+
{
848+
input: int64(9),
849+
quota: int64(1000),
850+
period: int64(100000),
851+
},
852+
{
853+
input: int64(10),
854+
quota: int64(1000),
855+
period: int64(100000),
856+
},
842857
{
843858
input: int64(200),
844859
quota: int64(20000),

0 commit comments

Comments
 (0)