kubernetes: Cgroup 'cpu.cfs_quota_us' error on container creation when CPU limit is low

After upgrading my environment from Kubernetes 1.1.8 to Kubernetes 1.2.0, I see pods creation failing with the following resource limits set:

        resources:
          limits:
            cpu: 5m
            memory: 25Mi

Translated to Docker container info:

1.1.8 1.2.0
“Memory”: 26214400, “Memory”: 26214400,
“MemoryReservation”: 0, “MemoryReservation”: 0,
“CpuShares”: 5, “CpuShares”: 5,
“CpuPeriod”: 0, “CpuPeriod”: 100000,
“CpuQuota”: 0, “CpuQuota”: 500,

The error message is:

Cannot start container <sha>: [9] System error: write /sys/fs/cgroup/cpu,cpuacct/system.slice/docker-<sha>.scope/cpu.cfs_quota_us: invalid argument

I can reproduce this by creating containers manually:

$ docker run --rm --cpu-shares=5 --cpu-quota=0 --cpu-period=0 tianon/true
[exit code 0]
$ docker run --rm --cpu-shares=5 --cpu-quota=500 --cpu-period=100000 tianon/true
docker: Error response from daemon: Cannot start container <sha>: [9] System error: write /sys/fs/cgroup/cpu,cpuacct/docker/<sha>/cpu.cfs_quota_us: invalid argument.
[exit code 125]

Kubernetes should check that the defined CPU restrictions are valid before attempting to create containers.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 19 (18 by maintainers)

Most upvoted comments

It works with limits.cpu = 10m, translated to:

            "CpuShares": 10,
            "CpuPeriod": 100000,
            "CpuQuota": 1000,

So now that I understand better, it will always fail with limits.cpu < 10m