diff options
author | Morten Tokle <mortent@oath.com> | 2017-11-10 11:00:50 +0100 |
---|---|---|
committer | Morten Tokle <mortent@oath.com> | 2017-11-10 11:09:07 +0100 |
commit | 95759dee5f972894d55d32599635d1363fa0d1ff (patch) | |
tree | 97d1cb172d2eab204502b0ec7f9b2234fe369a46 /config-model | |
parent | 29e8ff8314dfdf875c6fdd28cb4a4e6cc00aa694 (diff) |
Send lbaddress in identity config
Diffstat (limited to 'config-model')
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/container/Identity.java | 16 | ||||
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java | 19 |
2 files changed, 16 insertions, 19 deletions
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 81762f95a90..d3038a32bfe 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 @@ -5,6 +5,9 @@ import com.yahoo.container.core.identity.IdentityConfig; import com.yahoo.container.jdisc.athenz.impl.AthenzIdentityProviderImpl; import com.yahoo.vespa.model.container.component.SimpleComponent; +import java.net.URI; +import java.util.Optional; + /** * @author mortent */ @@ -13,9 +16,9 @@ public class Identity extends SimpleComponent implements IdentityConfig.Producer private final String domain; private final String service; - private final String loadBalancerAddress; + private final URI loadBalancerAddress; - public Identity(String domain, String service, String loadBalancerAddress) { + public Identity(String domain, String service, URI loadBalancerAddress) { super(CLASS); this.domain = domain; this.service = service; @@ -26,6 +29,13 @@ public class Identity extends SimpleComponent implements IdentityConfig.Producer public void getConfig(IdentityConfig.Builder builder) { builder.domain(domain); builder.service(service); - builder.loadBalancerAddress(loadBalancerAddress); + // Load balancer address might not have been set + // Current interpretation of loadbalancer address is: hostname. + // Config should be renamed or send the uri + builder.loadBalancerAddress( + Optional.ofNullable(loadBalancerAddress) + .map(URI::getHost) + .orElse("") + ); } } 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 32f2a59a881..f8d69d1b0ac 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,7 +7,6 @@ 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; @@ -18,7 +17,6 @@ import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.NodeType; import com.yahoo.container.jdisc.config.MetricDefaultsConfig; -import com.yahoo.log.LogLevel; import com.yahoo.search.rendering.RendererRegistry; import com.yahoo.text.XML; import com.yahoo.vespa.defaults.Defaults; @@ -168,8 +166,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { // Athenz copper argos // NOTE: Must be done after addNodes() - addIdentity(spec, cluster, context.getDeployState().getProperties().configServerSpecs(), - context.getDeployState().getProperties().loadBalancerAddress()); + addIdentity(spec, cluster, context.getDeployState().getProperties().loadBalancerAddress()); //TODO: overview handler, see DomQrserverClusterBuilder } @@ -697,23 +694,13 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { } } - private void addIdentity(Element element, ContainerCluster cluster, List<ConfigServerSpec> configServerSpecs, URI loadBalancerAddress) { + private void addIdentity(Element element, ContainerCluster cluster, URI loadBalancerAddress) { 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")); - // TODO: Remove after verifying that this is propagated correctly - logger.log(LogLevel.INFO, String.format("loadBalancerAddress: %s", loadBalancerAddress)); - - // TODO: Inject the load balancer address. For now only add first configserver - // TODO: The loadBalancerAddress is a URI, not specific host. - // TODO: Either rename loadBalancerAddress -> loadBalancerName (or similar) or - // TODO: make consumers of it use URI. - String cfgHostName = configServerSpecs.stream().findFirst().map(ConfigServerSpec::getHostName) - .orElse(""); // How to test this? - - Identity identity = new Identity(domain.trim(), service.trim(), cfgHostName); + Identity identity = new Identity(domain.trim(), service.trim(), loadBalancerAddress); cluster.addComponent(identity); cluster.getContainers().forEach(container -> { |