summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-07-14 13:40:14 +0200
committerGitHub <noreply@github.com>2022-07-14 13:40:14 +0200
commit3aadac85fa72b1c819a3e4601af644623da736c2 (patch)
tree25fc38e4b50287d74eea570b340a3ada8c913ac8 /config-model
parenta30a88869a8e174ba2b104a887e4917283a75799 (diff)
parent62e461bafef4c5ebe116a8c2cc4989b701b1cb58 (diff)
Merge pull request #23505 from vespa-engine/hmusum/fail-if-node-count-not-given-for-content-cluster-in-hosted
Fail deployment if node count is not given for content cluster in hosted
Diffstat (limited to 'config-model')
-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() {