aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src
diff options
context:
space:
mode:
authorHarald Musum <musum@yahooinc.com>2022-07-14 12:03:07 +0200
committerHarald Musum <musum@yahooinc.com>2022-07-14 12:04:07 +0200
commit62e461bafef4c5ebe116a8c2cc4989b701b1cb58 (patch)
tree2c3909bbe9e098c375c7067bcc8d9b1bb39b90bb /config-model/src
parent439da54cb6068d6097fc65bdd8e5d0e6d108d81a (diff)
Fail deployment if node count is not given for content cluster in hosted
Node count must be given for other zones than those that are manually deployed
Diffstat (limited to 'config-model/src')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/Content.java2
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/StorageGroup.java5
-rw-r--r--config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java32
3 files changed, 37 insertions, 2 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java b/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java
index 22923a724a6..fc2f68ccd92 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java
@@ -54,7 +54,7 @@ public class Content extends ConfigModel {
// Dependencies to other models
private final AdminModel adminModel;
- // to find or add the docproc container and supplement cluster controllers with clusters having less then 3 nodes
+ // to find or add the docproc container and supplement cluster controllers with clusters having less than 3 nodes
private final Collection<ContainerModel> containers;
@SuppressWarnings("UnusedDeclaration") // Created by reflection in ConfigModelRepo
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/StorageGroup.java b/config-model/src/main/java/com/yahoo/vespa/model/content/StorageGroup.java
index 8a8d2742df1..aef00be5ea9 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/StorageGroup.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/StorageGroup.java
@@ -442,6 +442,11 @@ public class StorageGroup {
nodeRequirement = Optional.of(NodesSpecification.from(nodesElement.get(), context));
else if (nodesElement.isEmpty() && subGroups.isEmpty() && context.getDeployState().isHosted()) // request one node
nodeRequirement = Optional.of(NodesSpecification.nonDedicated(1, context));
+ else if (nodesElement.isPresent() && nodesElement.get().stringAttribute("count") == null && context.getDeployState().isHosted())
+ throw new IllegalArgumentException("""
+ Clusters in hosted environments must have a <nodes count='N'> tag
+ matching all zones, and having no <node> subtags,
+ see https://cloud.vespa.ai/en/reference/services""");
else // Nodes or groups explicitly listed - resolve in GroupBuilder
nodeRequirement = Optional.empty();
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 f5ff48c0c69..03ab4f46c60 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
@@ -39,7 +39,6 @@ import com.yahoo.vespa.model.test.VespaModelTester;
import com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg;
import com.yahoo.yolean.Exceptions;
import org.junit.Test;
-
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
@@ -1662,6 +1661,37 @@ public class ModelProvisioningTest {
assertEquals(1, model.getAdmin().getClusterControllers().getContainers().size());
}
+ @Test
+ public void testThatStandaloneSyntaxWithClusterControllerWorksOnHostedManuallyDeployed() {
+ String services =
+ "<?xml version='1.0' encoding='utf-8' ?>" +
+ "<services>" +
+ " <container id='foo' version='1.0'>" +
+ " <nodes count=\"2\" />" +
+ " </container>" +
+ " <content id='bar' version='1.0'>" +
+ " <documents>" +
+ " <document type='type1' mode='index'/>" +
+ " </documents>" +
+ " <redundancy>1</redundancy>" +
+ " <nodes>" +
+ " <group>" +
+ " <node distribution-key='0' hostalias='node3'/>" +
+ " </group>" +
+ " </nodes>" +
+ " </content>" +
+ "</services>";
+ VespaModelTester tester = new VespaModelTester();
+ tester.setHosted(true);
+ tester.addHosts(4);
+ try {
+ VespaModel model = tester.createModel(new Zone(Environment.staging, RegionName.from("us-central-1")), services, true);
+ fail("expected failure");
+ } catch (IllegalArgumentException e) {
+ assertTrue(e.getMessage().startsWith("Clusters in hosted environments must have a <nodes count='N'> tag"));
+ }
+ }
+
/** Deploying an application with "nodes count" standalone should give a single-node deployment */
@Test
public void testThatHostedSyntaxWorksOnStandalone() {