Open VynDragon opened 4 years ago
I'm not sure I understand; you're setting the limit to a number higher than the number of available CPU's; isn't it expected to get an error in that case?
Well no, since it's a limit, not a requirement, and I don't expect a limit to throw a error when it's applicable (like, it currently seems to set a condition of if cpu_count > limit and cpu_available < limit, which doesn't make any sense as it sets a requirement, and a limit, and the requirement is not explicit) , and it's also quite handicapping when using different nodes with more or less cores. I'd only expect this error when using, for example here, --reserve-cpu 9, where it would make perfect sense.
Note also it seems to me it's a new behavior, as I didn't encounter it before updating recently.
To add to this, the behaviour between memory limits and CPU limits is different.
If the specified CPU limit is greater than the CPU count, a container will refuse to start. However, if the specified memory limit is greater than the actual memory count, the container will start just fine, although the set limit can never be reached.
I agree with @VynDragon that the expected behaviour should be that of the memory limit, whereby a software limit greater than the hardware limit can be set.
I'm not sure I understand; you're setting the limit to a number higher than the number of available CPU's; isn't it expected to get an error in that case?
@thaJeztah: No. If I configure a service to use no more than twelve CPUs, and I deploy it to a machine having only eight CPUs, I would not expect a problem, since the service obviously will not be using more than twelve CPUs. (My use case is that I want to limit a particular service to use no more than two CPUs in production while being able to test it on a single-core VM.)
I think the relevant code is at daemon/daemon_unix.go, lines 520–522:
if resources.NanoCPUs < 0 || resources.NanoCPUs > int64(sysinfo.NumCPU())*1e9 {
return warnings, fmt.Errorf("Range of CPUs is from 0.01 to %d.00, as there are only %d CPUs available", sysinfo.NumCPU(), sysinfo.NumCPU())
}
This was added by 846baf1fd3 ("Add --cpus flag to control cpu resources"). @yongtang: Could the check resources.NanoCPUs > int64(sysinfo.NumCPU()) * 1e9
be removed?
Hi, I manage a docker swarm with heterogeneous nodes, and today I got a new error that is preventing some services from starting instances on nodes where the CPU core count is lower.
Steps to reproduce the issue:
Describe the results you received: getting "Range of CPUs is from 0.01 to 8.00, as there are only 8 CPUs available" and instance not starting
Describe the results you expected: Get no error and the instance start, because 8 < 12.
Additional information you deem important (e.g. issue happens only occasionally): When the "limit-cpu" restriction is removed, the instances start normally on that node
Output of
docker version
:docker version server:
docker version node:
Output of
docker info
: servernode (after removing cpu-limit)
Additional environment details (AWS, VirtualBox, physical, etc.): All physical.