diff options
-rw-r--r-- | docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/DockerImpl.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/DockerImpl.java b/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/DockerImpl.java index 3504d789333..bafa11f2a06 100644 --- a/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/DockerImpl.java +++ b/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/DockerImpl.java @@ -288,7 +288,12 @@ public class DockerImpl implements Docker { } private static ContainerResources containerResourcesFromHostConfig(HostConfig hostConfig) { - final double cpus = hostConfig.getCpuPeriod() > 0 ? + // Docker keeps an internal state of what the period and quota are: in cgroups, the quota is always set + // (default is 100000), but docker will report it as 0 unless explicitly set by the user. + // This may lead to a state where the quota is set, but period is 0 (accord to docker), which will + // mess up the calculation below. This can only happen if someone sets it manually, since this class + // will always set both quota and period. + final double cpus = hostConfig.getCpuQuota() > 0 ? (double) hostConfig.getCpuQuota() / hostConfig.getCpuPeriod() : 0; return new ContainerResources(cpus, hostConfig.getCpuShares(), hostConfig.getMemory()); } |