aboutsummaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2023-01-21 17:50:10 +0100
committerJon Bratseth <bratseth@gmail.com>2023-01-21 17:50:10 +0100
commit7a6af9caa065b3ab63b094d78b7347d7df6bea0f (patch)
tree48e80650a9cd88016ff8e618d85d727a28f3542c /config-model
parent00d86602a88c66486c8f4c68a1c8bdff096c7273 (diff)
Support a group size constraint in content clusters
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/NodesSpecification.java12
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java2
-rw-r--r--config-model/src/main/resources/schema/content.rnc3
-rw-r--r--config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java4
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/CloudAccountChangeValidatorTest.java2
-rw-r--r--config-model/src/test/schema-test-files/services-hosted.xml2
6 files changed, 20 insertions, 5 deletions
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 aac968f9038..d3cf5c531e1 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
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.builder.xml.dom;
+import com.yahoo.collections.IntRange;
import com.yahoo.collections.Pair;
import com.yahoo.component.Version;
import com.yahoo.config.application.api.DeployLogger;
@@ -34,6 +35,8 @@ public class NodesSpecification {
private final ClusterResources min, max;
+ private final IntRange groupSize;
+
private final boolean dedicated;
/** The Vespa version we want the nodes to run */
@@ -63,6 +66,7 @@ public class NodesSpecification {
private NodesSpecification(ClusterResources min,
ClusterResources max,
+ IntRange groupSize,
boolean dedicated, Version version,
boolean required, boolean canFail, boolean exclusive,
Optional<DockerImage> dockerImageRepo,
@@ -83,6 +87,7 @@ public class NodesSpecification {
this.min = min;
this.max = max;
+ this.groupSize = groupSize;
this.dedicated = dedicated;
this.version = version;
this.required = required;
@@ -103,6 +108,7 @@ public class NodesSpecification {
boolean hasCountAttribute = resolvedElement.stringAttribute("count") != null;
return new NodesSpecification(resources.getFirst(),
resources.getSecond(),
+ IntRange.from(resolvedElement.stringAttribute("group-size", "")),
dedicated,
version,
resolvedElement.booleanAttribute("required", false),
@@ -178,6 +184,7 @@ public class NodesSpecification {
public static NodesSpecification nonDedicated(int count, ConfigModelContext context) {
return new NodesSpecification(new ClusterResources(count, 1, NodeResources.unspecified()),
new ClusterResources(count, 1, NodeResources.unspecified()),
+ IntRange.empty(),
false,
context.getDeployState().getWantedNodeVespaVersion(),
false,
@@ -193,6 +200,7 @@ public class NodesSpecification {
public static NodesSpecification dedicated(int count, ConfigModelContext context) {
return new NodesSpecification(new ClusterResources(count, 1, NodeResources.unspecified()),
new ClusterResources(count, 1, NodeResources.unspecified()),
+ IntRange.empty(),
true,
context.getDeployState().getWantedNodeVespaVersion(),
false,
@@ -219,6 +227,7 @@ public class NodesSpecification {
.toList();
return new NodesSpecification(new ClusterResources(count, 1, resources),
new ClusterResources(count, 1, resources),
+ IntRange.empty(),
true,
context.getDeployState().getWantedNodeVespaVersion(),
allContent.stream().anyMatch(content -> content.required),
@@ -232,6 +241,7 @@ public class NodesSpecification {
public ClusterResources minResources() { return min; }
public ClusterResources maxResources() { return max; }
+ public IntRange groupSize() { return groupSize; }
/**
* Returns whether this requires dedicated nodes.
@@ -275,7 +285,7 @@ public class NodesSpecification {
.loadBalancerSettings(zoneEndpoint)
.stateful(stateful)
.build();
- return hostSystem.allocateHosts(cluster, Capacity.from(min, max, required, canFail, cloudAccount), logger);
+ return hostSystem.allocateHosts(cluster, Capacity.from(min, max, groupSize, required, canFail, cloudAccount), logger);
}
private static Pair<NodeResources, NodeResources> nodeResources(ModelElement nodesElement) {
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 4c7bad575d2..7b1876db457 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
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container.xml;
+import com.yahoo.collections.IntRange;
import com.yahoo.component.ComponentSpecification;
import com.yahoo.component.Version;
import com.yahoo.component.chain.dependencies.Dependencies;
@@ -926,6 +927,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
ClusterResources resources = new ClusterResources(nodeCount, 1, NodeResources.unspecified());
Capacity capacity = Capacity.from(resources,
resources,
+ IntRange.empty(),
false,
!deployState.getProperties().isBootstrap(),
context.getDeployState().getProperties().cloudAccount());
diff --git a/config-model/src/main/resources/schema/content.rnc b/config-model/src/main/resources/schema/content.rnc
index 3d1873507ce..703001f0107 100644
--- a/config-model/src/main/resources/schema/content.rnc
+++ b/config-model/src/main/resources/schema/content.rnc
@@ -226,7 +226,8 @@ ContentNodes = element nodes {
attribute required { xsd:boolean }? &
attribute exclusive { xsd:boolean }? &
attribute docker-image { xsd:string }? &
- attribute groups { xsd:positiveInteger | xsd:string }?
+ attribute groups { xsd:positiveInteger | xsd:string }? &
+ attribute group-size { xsd:positiveInteger | xsd:string }?
)
|
ContentNode +
diff --git a/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java b/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java
index 635ed4c8659..a6ddce4cec5 100644
--- a/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java
+++ b/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java
@@ -501,14 +501,14 @@ public class ModelProvisioningTest {
" <documents>" +
" <document type='type1' mode='index'/>" +
" </documents>" +
- " <nodes count='27' groups='9'/>" +
+ " <nodes count='27' groups='9' group-size='[2, 3]'/>" +
" </content>" +
" <content version='1.0' id='baz'>" +
" <redundancy>1</redundancy>" +
" <documents>" +
" <document type='type1' mode='index'/>" +
" </documents>" +
- " <nodes count='27' groups='27'/>" +
+ " <nodes count='27' groups='27' group-size='1'/>" +
" </content>" +
"</services>";
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/CloudAccountChangeValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/CloudAccountChangeValidatorTest.java
index 46d0fcb3123..91493bab480 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/CloudAccountChangeValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/CloudAccountChangeValidatorTest.java
@@ -1,5 +1,6 @@
package com.yahoo.vespa.model.application.validation.change;
+import com.yahoo.collections.IntRange;
import com.yahoo.config.application.api.ValidationOverrides;
import com.yahoo.config.model.api.Provisioned;
import com.yahoo.config.model.deploy.DeployState;
@@ -55,6 +56,7 @@ class CloudAccountChangeValidatorTest {
NodeResources nodeResources = new NodeResources(4, 8, 100, 10);
return Capacity.from(new ClusterResources(2, 1, nodeResources),
new ClusterResources(2, 1, nodeResources),
+ IntRange.empty(),
false,
false,
Optional.of(cloudAccount).filter(account -> !account.isUnspecified()));
diff --git a/config-model/src/test/schema-test-files/services-hosted.xml b/config-model/src/test/schema-test-files/services-hosted.xml
index caf56881475..2697cc871e2 100644
--- a/config-model/src/test/schema-test-files/services-hosted.xml
+++ b/config-model/src/test/schema-test-files/services-hosted.xml
@@ -31,7 +31,7 @@
<content id="ml" version="1.0">
<redundancy>2</redundancy>
- <nodes count="[10,20]" flavor="large" groups="[1,3]" vespamalloc-debug-stacktrace="proton">
+ <nodes count="[10,20]" flavor="large" groups="[1,3]" group-size="[1,2]" vespamalloc-debug-stacktrace="proton">
<resources vcpu="[3.0, 4]" memory="[32000.0Mb, 33Gb]" disk="[300 Gb, 1Tb]"/>
</nodes>
</content>