diff options
author | Bjørn Christian Seime <bjorn.christian@seime.no> | 2017-10-26 12:14:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-26 12:14:38 +0200 |
commit | 0fc6803250232aa72ec63b88c36f496373ba76dc (patch) | |
tree | bd32784643f8e4ba78cd089799a1f8cb9702e9b3 | |
parent | 78658b1d99dd881485ace8855fee15832d1a6a75 (diff) | |
parent | 3e7849ecba7346026a7a79a476899fbf688ad5d0 (diff) |
Merge pull request #3898 from vespa-engine/mortent/read-configserver-in-builder
Read configserver hostname while constructing identity
3 files changed, 14 insertions, 11 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java index 44b49a8f842..b7482a3646d 100755 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java @@ -13,7 +13,6 @@ import com.yahoo.config.application.api.DeploymentSpec; import com.yahoo.config.docproc.DocprocConfig; import com.yahoo.config.docproc.SchemamappingConfig; import com.yahoo.config.model.ApplicationConfigProducerRoot; -import com.yahoo.config.model.api.ConfigServerSpec; import com.yahoo.config.model.producer.AbstractConfigProducer; import com.yahoo.config.model.producer.AbstractConfigProducerRoot; import com.yahoo.config.provision.Rotation; @@ -873,11 +872,6 @@ public final class ContainerCluster @Override public void getConfig(IdentityConfig.Builder builder) { if (identity != null) { - // TODO: Inject the load balancer address. For now only add first configserver - String cfgHostName = getRoot().getDeployState().getProperties() - .configServerSpecs().stream().findFirst().map(ConfigServerSpec::getHostName) - .orElse(""); // How to test this? - builder.loadBalancerAddress(cfgHostName); identity.getConfig(builder); } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/Identity.java b/config-model/src/main/java/com/yahoo/vespa/model/container/Identity.java index 665da9ec426..ffa2bbb9c7b 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/Identity.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/Identity.java @@ -10,16 +10,19 @@ import com.yahoo.vespa.model.container.component.SimpleComponent; public class Identity extends SimpleComponent implements IdentityConfig.Producer { private final String domain; private final String service; + private final String loadBalancerAddress; - public Identity(String domain, String service) { + public Identity(String domain, String service, String loadBalancerAddress) { super("com.yahoo.container.jdisc.athenz.impl.AthenzIdentityProviderImpl"); this.domain = domain; this.service = service; + this.loadBalancerAddress = loadBalancerAddress; } @Override public void getConfig(IdentityConfig.Builder builder) { builder.domain(domain); builder.service(service); + builder.loadBalancerAddress(loadBalancerAddress); } } 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 0d221b57748..f00e6e5e271 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 @@ -7,6 +7,7 @@ import com.yahoo.config.application.Xml; import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.config.model.ConfigModelContext; +import com.yahoo.config.model.api.ConfigServerSpec; import com.yahoo.config.model.application.provider.IncludeDirs; import com.yahoo.config.model.builder.xml.ConfigModelBuilder; import com.yahoo.config.model.builder.xml.ConfigModelId; @@ -22,7 +23,6 @@ import com.yahoo.text.XML; import com.yahoo.vespa.defaults.Defaults; import com.yahoo.vespa.model.AbstractService; import com.yahoo.vespa.model.HostResource; -import com.yahoo.vespa.model.container.Identity; import com.yahoo.vespa.model.builder.xml.dom.DomClientProviderBuilder; import com.yahoo.vespa.model.builder.xml.dom.DomComponentBuilder; import com.yahoo.vespa.model.builder.xml.dom.DomFilterBuilder; @@ -38,6 +38,7 @@ import com.yahoo.vespa.model.clients.ContainerDocumentApi; import com.yahoo.vespa.model.container.Container; import com.yahoo.vespa.model.container.ContainerCluster; import com.yahoo.vespa.model.container.ContainerModel; +import com.yahoo.vespa.model.container.Identity; import com.yahoo.vespa.model.container.component.Component; import com.yahoo.vespa.model.container.component.FileStatusHandlerComponent; import com.yahoo.vespa.model.container.component.chain.ProcessingHandler; @@ -161,7 +162,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { addLegacyFilters(spec, cluster); // TODO: Remove for Vespa 7 // Athenz copper argos - addIdentity(spec, cluster); + addIdentity(spec, cluster, context.getDeployState().getProperties().configServerSpecs()); //TODO: overview handler, see DomQrserverClusterBuilder } @@ -689,12 +690,17 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { } } - private void addIdentity(Element element, ContainerCluster cluster) { + private void addIdentity(Element element, ContainerCluster cluster, List<ConfigServerSpec> configServerSpecs) { Element identityElement = XML.getChild(element, "identity"); if(identityElement != null) { String domain = XML.getValue(XML.getChild(identityElement, "domain")); String service = XML.getValue(XML.getChild(identityElement, "service")); - Identity identity = new Identity(domain.trim(), service.trim()); + + // TODO: Inject the load balancer address. For now only add first configserver + String cfgHostName = configServerSpecs.stream().findFirst().map(ConfigServerSpec::getHostName) + .orElse(""); // How to test this? + + Identity identity = new Identity(domain.trim(), service.trim(), cfgHostName); cluster.setIdentity(identity); } } |