diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-03-20 21:23:51 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-03-20 21:23:51 +0100 |
commit | 75df844174e47bec91a3067ab50b16a9833fd5f0 (patch) | |
tree | 50770bc317f9cff020751ae4c8f6b1919423fd9b /config-model | |
parent | 601b4777257e9d1694bdc6987d2b63ee6ccf52dc (diff) |
Allow applications to request exlcusive access to hosts
Diffstat (limited to 'config-model')
5 files changed, 49 insertions, 13 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/provision/InMemoryProvisioner.java b/config-model/src/main/java/com/yahoo/config/model/provision/InMemoryProvisioner.java index fb58a991012..2e1d507eea1 100644 --- a/config-model/src/main/java/com/yahoo/config/model/provision/InMemoryProvisioner.java +++ b/config-model/src/main/java/com/yahoo/config/model/provision/InMemoryProvisioner.java @@ -4,9 +4,24 @@ package com.yahoo.config.model.provision; import com.yahoo.collections.ListMap; import com.yahoo.collections.Pair; import com.yahoo.config.model.api.HostProvisioner; -import com.yahoo.config.provision.*; - -import java.util.*; +import com.yahoo.config.provision.Capacity; +import com.yahoo.config.provision.ClusterMembership; +import com.yahoo.config.provision.ClusterSpec; +import com.yahoo.config.provision.HostSpec; +import com.yahoo.config.provision.ProvisionLogger; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Optional; +import java.util.Set; /** * In memory host provisioner. NB! ATM cannot be reused after allocate has been called. @@ -111,11 +126,14 @@ public class InMemoryProvisioner implements HostProvisioner { List<HostSpec> allocation = new ArrayList<>(); if (groups == 1) { - allocation.addAll(allocateHostGroup(cluster, flavor, capacity, startIndexForClusters)); + allocation.addAll(allocateHostGroup(cluster.with(Optional.of(ClusterSpec.Group.from(0))), + flavor, + capacity, + startIndexForClusters)); } else { for (int i = 0; i < groups; i++) { - allocation.addAll(allocateHostGroup(cluster.changeGroup(Optional.of(ClusterSpec.Group.from(i))), + allocation.addAll(allocateHostGroup(cluster.with(Optional.of(ClusterSpec.Group.from(i))), flavor, capacity / groups, allocation.size())); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/NodesSpecification.java b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/NodesSpecification.java index 61dee04a444..f7ed7241133 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/NodesSpecification.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/NodesSpecification.java @@ -38,16 +38,20 @@ public class NodesSpecification { /** The flavor the nodes should have, or empty to use the default */ private final Optional<String> flavor; + private final boolean exclusive; + /** The identifier of the custom docker image layer to use (not supported yet) */ private final Optional<String> dockerImage; private NodesSpecification(boolean dedicated, int count, int groups, Version version, boolean required, + boolean exclusive, Optional<String> flavor, Optional<String> dockerImage) { this.dedicated = dedicated; this.count = count; this.groups = groups; this.version = version; this.required = required; + this.exclusive = exclusive; this.flavor = flavor; this.dockerImage = dockerImage; } @@ -58,6 +62,7 @@ public class NodesSpecification { nodesElement.getIntegerAttribute("groups", 1), version, nodesElement.getBooleanAttribute("required", false), + nodesElement.getBooleanAttribute("exclusive", false), Optional.ofNullable(nodesElement.getStringAttribute("flavor")), Optional.ofNullable(nodesElement.getStringAttribute("docker-image"))); } @@ -90,12 +95,14 @@ public class NodesSpecification { if (parentElement == null) return Optional.empty(); ModelElement nodesElement = parentElement.getChild("nodes"); if (nodesElement == null) return Optional.empty(); - return Optional.of(new NodesSpecification(nodesElement.getBooleanAttribute("dedicated", false), version, nodesElement)); + return Optional.of(new NodesSpecification(nodesElement.getBooleanAttribute("dedicated", false), + version, nodesElement)); } /** Returns a requirement from <code>count</code> nondedicated nodes in one group */ public static NodesSpecification nonDedicated(int count, Version version) { - return new NodesSpecification(false, count, 1, version, false, Optional.empty(), Optional.empty()); + return new NodesSpecification(false, count, 1, version, false, false, + Optional.empty(), Optional.empty()); } /** @@ -104,6 +111,13 @@ public class NodesSpecification { */ public boolean isDedicated() { return dedicated; } + /** + * Returns whether the physical hosts running the nodes of this application can + * also run nodes of other applications. Using exclusive nodes for containers increases security + * and increases cost. + */ + public boolean isExclusive() { return exclusive; } + /** Returns the number of nodes required */ public int count() { return count; } @@ -111,7 +125,7 @@ public class NodesSpecification { public int groups() { return groups; } public Map<HostResource, ClusterMembership> provision(HostSystem hostSystem, ClusterSpec.Type clusterType, ClusterSpec.Id clusterId, DeployLogger logger) { - ClusterSpec cluster = ClusterSpec.request(clusterType, clusterId, version); + ClusterSpec cluster = ClusterSpec.request(clusterType, clusterId, version, exclusive); return hostSystem.allocateHosts(cluster, Capacity.fromNodeCount(count, flavor, required), groups, logger); } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java index 4caf0baf012..39aba9cfdf9 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java @@ -509,7 +509,10 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { return singleContentHost.get(); } else { // request 1 node - ClusterSpec clusterSpec = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from(cluster.getName()), context.getDeployState().getWantedNodeVespaVersion()); + ClusterSpec clusterSpec = ClusterSpec.request(ClusterSpec.Type.container, + ClusterSpec.Id.from(cluster.getName()), + context.getDeployState().getWantedNodeVespaVersion(), + false); return cluster.getHostSystem().allocateHosts(clusterSpec, Capacity.fromNodeCount(1), 1, logger).keySet().iterator().next(); } } else { @@ -531,7 +534,8 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { NodeType type = NodeType.valueOf(nodesElement.getAttribute("type")); ClusterSpec clusterSpec = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from(cluster.getName()), - context.getDeployState().getWantedNodeVespaVersion()); + context.getDeployState().getWantedNodeVespaVersion(), + false); Map<HostResource, ClusterMembership> hosts = cluster.getRoot().getHostSystem().allocateHosts(clusterSpec, Capacity.fromRequiredNodeType(type), 1, log); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/HostResourceTest.java b/config-model/src/test/java/com/yahoo/vespa/model/HostResourceTest.java index 1a0e9b9f810..28e3dd9be78 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/HostResourceTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/HostResourceTest.java @@ -144,7 +144,7 @@ public class HostResourceTest { } private static ClusterSpec clusterSpec(ClusterSpec.Type type, String id) { - return ClusterSpec.from(type, ClusterSpec.Id.from(id), ClusterSpec.Group.from(0), Version.fromString("6.42")); + return ClusterSpec.from(type, ClusterSpec.Id.from(id), ClusterSpec.Group.from(0), Version.fromString("6.42"), false); } private HostResource mockHostResource() { diff --git a/config-model/src/test/java/com/yahoo/vespa/model/VespaModelFactoryTest.java b/config-model/src/test/java/com/yahoo/vespa/model/VespaModelFactoryTest.java index b5934da3178..cabe9c0969b 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/VespaModelFactoryTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/VespaModelFactoryTest.java @@ -117,7 +117,7 @@ public class VespaModelFactoryTest { ClusterMembership.from(ClusterSpec.from(ClusterSpec.Type.admin, new ClusterSpec.Id(routingClusterName), ClusterSpec.Group.from(0), - Version.fromString("6.42")), + Version.fromString("6.42"), false), 0)); } @@ -128,7 +128,7 @@ public class VespaModelFactoryTest { ClusterMembership.from(ClusterSpec.from(ClusterSpec.Type.container, new ClusterSpec.Id(routingClusterName), ClusterSpec.Group.from(0), - Version.fromString("6.42")), + Version.fromString("6.42"), false), 0))); } }; |