diff options
-rw-r--r-- | docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/ContainerResources.java | 31 | ||||
-rw-r--r-- | node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java | 8 |
2 files changed, 23 insertions, 16 deletions
diff --git a/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/ContainerResources.java b/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/ContainerResources.java index d6462b823f1..1b0b6380481 100644 --- a/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/ContainerResources.java +++ b/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/ContainerResources.java @@ -7,17 +7,22 @@ import java.util.Objects; * @author valerijf */ public class ContainerResources { + public static final ContainerResources UNLIMITED = ContainerResources.from(0, 0, 0); private static final int CPU_PERIOD = 100_000; // 100 µs - /** Hard limit on container's CPU usage: Implemented using Completely Fair Scheduler (CFS) by allocating a given + /** + * Hard limit on container's CPU usage: Implemented using Completely Fair Scheduler (CFS) by allocating a given * time within a given period, Container's processes are not bound to any specific CPU, which may create significant - * performance degradation as processes are scheduled on another CPU after exhausting the quota. */ + * performance degradation as processes are scheduled on another CPU after exhausting the quota. + */ private final double cpus; - /** Soft limit on container's CPU usage: When plenty of CPU cycles are available, all containers use as much + /** + * Soft limit on container's CPU usage: When plenty of CPU cycles are available, all containers use as much * CPU as they need. It prioritizes container CPU resources for the available CPU cycles. - * It does not guarantee or reserve any specific CPU access. */ + * It does not guarantee or reserve any specific CPU access. + */ private final int cpuShares; /** The maximum amount, in bytes, of memory the container can use. */ @@ -36,11 +41,20 @@ public class ContainerResources { throw new IllegalArgumentException("memoryBytes must be a positive integer or 0 for unlimited, was " + memoryBytes); } + /** + * Create container resources from required fields. + * + * @param cpus the amount of vcpu that should be exclusively available to this container. This is a hard limit: + * More than this amlunt will never be available. To allow an unlimited amount use 0. + * @param cpuCores the amount of vcpu that should ideally be allocated to this container if there are no other + * constraints on resources. To allow an unlimited amount use 0. + * @param memoryGb the exact amount of memory that must be available to this container. + * @return the container resources encapsulating the parameters + */ public static ContainerResources from(double cpus, double cpuCores, double memoryGb) { - return new ContainerResources( - cpus, - (int) Math.round(10 * cpuCores), - (long) ((1L << 30) * memoryGb)); + return new ContainerResources(cpus, + (int) Math.round(10 * cpuCores), + (long) ((1L << 30) * memoryGb)); } public double cpus() { @@ -65,7 +79,6 @@ public class ContainerResources { return memoryBytes; } - /** Returns true iff the memory component(s) of between <code>this</code> and <code>other</code> are equal */ public boolean equalsMemory(ContainerResources other) { return memoryBytes == other.memoryBytes; diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java index c8e280c0c78..6dfcf3e9aec 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java @@ -60,7 +60,7 @@ public class DockerOperationsImpl implements DockerOperations { // IPv6 - Assume always valid Inet6Address ipV6Address = ipAddresses.getIPv6Address(context.node().getHostname()).orElseThrow( () -> new RuntimeException("Unable to find a valid IPv6 address for " + context.node().getHostname() + - ". Missing an AAAA DNS entry?")); + ". Missing an AAAA DNS entry?")); Docker.CreateContainerCommand command = docker.createContainerCommand( context.node().getWantedDockerImage().get(), context.containerName()) @@ -76,12 +76,6 @@ public class DockerOperationsImpl implements DockerOperations { // // From experience our Vespa processes require a high limit, say 400k. For all other processes, // we would like to use a much lower limit, say 32k. - // - // Unfortunately, the Vespa processes runs as the yahoo user which is also used by many non-Vespa - // processes. This means all yahoo users must use the high limit. For instance, yinst would start - // many yahoo processes along with root processes and other processes. It's non-trivial to get this - // exactly right. Instead and for now, we just set a high limit here which will apply to all processes - // in the container, unless explicitly modified. .withUlimit("nproc", 409_600, 409_600) .withUlimit("core", -1, -1) .withAddCapability("SYS_PTRACE") // Needed for gcore, pstack etc. |