diff options
author | Valerij Fredriksen <valerijf@oath.com> | 2019-01-15 14:07:31 +0100 |
---|---|---|
committer | Valerij Fredriksen <valerijf@oath.com> | 2019-01-15 14:08:22 +0100 |
commit | 4f777c975c2e4af4fbbb30a9e547c965595b628b (patch) | |
tree | 6310296fc1f96697689153940091a20b21d5da28 /docker-api | |
parent | 5c4e2de4728c75a6787013bd2f0e91d3c1f71f5c (diff) |
Ignore negative or zero quota
Diffstat (limited to 'docker-api')
-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()); } |