summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2023-10-04 15:39:46 +0200
committerGitHub <noreply@github.com>2023-10-04 15:39:46 +0200
commit73a7347427cd4816582beca2a9b74256d0fc8d80 (patch)
tree5d44db84b068b361fc036a43964d8a0aecb8e92f /controller-server
parent6a05219150ff1c5f204a069e5aadb8e8af42525b (diff)
parentc1d6226504d99b503ec720ade82b2894980218b2 (diff)
Merge pull request #28791 from vespa-engine/mpolden/optional-container-id
Make container ID optional in BasicServicesXml
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/BasicServicesXml.java5
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/pkg/BasicServicesXmlTest.java4
2 files changed, 6 insertions, 3 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/BasicServicesXml.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/BasicServicesXml.java
index 8f3a02528fe..6a634cb8f53 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/BasicServicesXml.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/BasicServicesXml.java
@@ -9,7 +9,6 @@ import org.w3c.dom.Element;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
-import java.util.TreeSet;
/**
* A partially parsed variant of services.xml, for use by the {@link com.yahoo.vespa.hosted.controller.Controller}.
@@ -40,7 +39,9 @@ public record BasicServicesXml(List<Container> containers) {
for (var childNode : XML.getChildren(root)) {
if (childNode.getTagName().equals(CONTAINER_TAG)) {
String id = childNode.getAttribute("id");
- if (id.isEmpty()) throw new IllegalArgumentException(CONTAINER_TAG + " tag requires 'id' attribute");
+ if (id.isEmpty()) {
+ id = CONTAINER_TAG; // ID defaults to tag name when unset. See ConfigModelBuilder::getIdString
+ }
List<Container.AuthMethod> methods = new ArrayList<>();
List<TokenId> tokens = new ArrayList<>();
parseAuthMethods(childNode, methods, tokens);
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/pkg/BasicServicesXmlTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/pkg/BasicServicesXmlTest.java
index c28185466b0..f7bd1e06e68 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/pkg/BasicServicesXmlTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/pkg/BasicServicesXmlTest.java
@@ -18,11 +18,13 @@ class BasicServicesXmlTest {
public void parse() {
assertServices(new BasicServicesXml(List.of()), "<services/>");
assertServices(new BasicServicesXml(List.of(new Container("foo", List.of(Container.AuthMethod.mtls), List.of()),
- new Container("bar", List.of(Container.AuthMethod.mtls), List.of()))),
+ new Container("bar", List.of(Container.AuthMethod.mtls), List.of()),
+ new Container("container", List.of(Container.AuthMethod.mtls), List.of()))),
"""
<services>
<container id="foo"/>
<container id="bar"/>
+ <container/>
</services>
""");
assertServices(new BasicServicesXml(List.of(