diff options
author | Morten Tokle <morten.tokle@gmail.com> | 2017-11-16 19:00:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-16 19:00:44 +0100 |
commit | 9a7bbe64b2e0403651c06ddf7dc6ac841165433a (patch) | |
tree | 797fc2b68976a28ff60e506dae31c9c574d209ca /config-model | |
parent | 4b547d35f10f2c5c70a620131f1fad9343e89878 (diff) | |
parent | 32ec23d54aad2a32584446470faaa33e76cd773e (diff) |
Merge pull request #4145 from vespa-engine/mortent/add-lbaddress-name
Add new field for loadbalancername, deprecate loadbalanceraddress
Diffstat (limited to 'config-model')
6 files changed, 43 insertions, 33 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployProperties.java b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployProperties.java index 942320ecd40..3e96b225226 100644 --- a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployProperties.java +++ b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployProperties.java @@ -3,10 +3,10 @@ package com.yahoo.config.model.deploy; import com.yahoo.config.model.api.ConfigServerSpec; import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.Version; import com.yahoo.config.provision.Zone; -import java.net.URI; import java.util.ArrayList; import java.util.List; @@ -21,7 +21,7 @@ public class DeployProperties { private final boolean multitenant; private final ApplicationId applicationId; private final List<ConfigServerSpec> serverSpecs = new ArrayList<>(); - private final URI loadBalancerAddress; + private final HostName loadBalancerName; private final boolean hostedVespa; private final Version vespaVersion; private final Zone zone; @@ -29,11 +29,11 @@ public class DeployProperties { private DeployProperties(boolean multitenant, ApplicationId applicationId, List<ConfigServerSpec> configServerSpecs, - URI loadBalancerAddress, + HostName loadBalancerName, boolean hostedVespa, Version vespaVersion, Zone zone) { - this.loadBalancerAddress = loadBalancerAddress; + this.loadBalancerName = loadBalancerName; this.vespaVersion = vespaVersion; this.zone = zone; this.multitenant = multitenant || hostedVespa || Boolean.getBoolean("multitenant"); @@ -55,8 +55,8 @@ public class DeployProperties { return serverSpecs; } - public URI loadBalancerAddress() { - return loadBalancerAddress; + public HostName loadBalancerName() { + return loadBalancerName; } public boolean hostedVespa() { @@ -75,7 +75,7 @@ public class DeployProperties { private ApplicationId applicationId = ApplicationId.defaultId(); private boolean multitenant = false; private List<ConfigServerSpec> configServerSpecs = new ArrayList<>(); - private URI loadBalancerAddress; + private HostName loadBalancerName; private boolean hostedVespa = false; private Version vespaVersion = Version.fromIntValues(1, 0, 0); private Zone zone = Zone.defaultZone(); @@ -95,8 +95,8 @@ public class DeployProperties { return this; } - public Builder loadBalancerAddress(URI loadBalancerAddress) { - this.loadBalancerAddress = loadBalancerAddress; + public Builder loadBalancerName(HostName loadBalancerName) { + this.loadBalancerName = loadBalancerName; return this; } @@ -116,7 +116,7 @@ public class DeployProperties { } public DeployProperties build() { - return new DeployProperties(multitenant, applicationId, configServerSpecs, loadBalancerAddress, hostedVespa, vespaVersion, zone); + return new DeployProperties(multitenant, applicationId, configServerSpecs, loadBalancerName, hostedVespa, vespaVersion, zone); } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java b/config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java index 56db1542de8..74512e70ebe 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java @@ -147,7 +147,7 @@ public class VespaModelFactory implements ModelFactory { return new DeployProperties.Builder() .applicationId(properties.applicationId()) .configServerSpecs(properties.configServerSpecs()) - .loadBalancerAddress(properties.loadBalancerAddress()) + .loadBalancerName(properties.loadBalancerName()) .multitenant(properties.multitenant()) .hostedVespa(properties.hostedVespa()) .vespaVersion(getVersion()) 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 d3038a32bfe..bc7a6e20361 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 @@ -1,13 +1,11 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.container; +import com.yahoo.config.provision.HostName; 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 */ @@ -16,26 +14,21 @@ public class Identity extends SimpleComponent implements IdentityConfig.Producer private final String domain; private final String service; - private final URI loadBalancerAddress; + private final HostName loadBalancerName; - public Identity(String domain, String service, URI loadBalancerAddress) { + public Identity(String domain, String service, HostName loadBalancerName) { super(CLASS); this.domain = domain; this.service = service; - this.loadBalancerAddress = loadBalancerAddress; + this.loadBalancerName = loadBalancerName; } @Override public void getConfig(IdentityConfig.Builder builder) { builder.domain(domain); builder.service(service); - // 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("") - ); + builder.loadBalancerAddress(loadBalancerName.value()); } } 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 f8d69d1b0ac..d59846cd5e2 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; @@ -15,6 +16,7 @@ import com.yahoo.config.provision.Capacity; import com.yahoo.config.provision.ClusterMembership; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.Environment; +import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.NodeType; import com.yahoo.container.jdisc.config.MetricDefaultsConfig; import com.yahoo.search.rendering.RendererRegistry; @@ -57,7 +59,6 @@ import com.yahoo.vespa.model.content.StorageGroup; import org.w3c.dom.Element; import org.w3c.dom.Node; -import java.net.URI; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -166,7 +167,10 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { // Athenz copper argos // NOTE: Must be done after addNodes() - addIdentity(spec, cluster, context.getDeployState().getProperties().loadBalancerAddress()); + addIdentity(spec, + cluster, + context.getDeployState().getProperties().configServerSpecs(), + context.getDeployState().getProperties().loadBalancerName()); //TODO: overview handler, see DomQrserverClusterBuilder } @@ -694,13 +698,22 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { } } - private void addIdentity(Element element, ContainerCluster cluster, URI loadBalancerAddress) { + private void addIdentity(Element element, ContainerCluster cluster, List<ConfigServerSpec> configServerSpecs, HostName loadBalancerName) { 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(), loadBalancerAddress); + // Set lbaddress, or use first hostname if not specified. + HostName lbName = Optional.ofNullable(loadBalancerName) + .orElseGet( + () -> HostName.from(configServerSpecs.stream() + .findFirst() + .map(ConfigServerSpec::getHostName) + .orElse("unknown") // Currently unable to test this, hence the unknown + )); + + Identity identity = new Identity(domain.trim(), service.trim(), lbName); cluster.addComponent(identity); cluster.getContainers().forEach(container -> { diff --git a/config-model/src/test/java/com/yahoo/config/model/MockModelContext.java b/config-model/src/test/java/com/yahoo/config/model/MockModelContext.java index ff37fb1fad3..58f83d1e4e6 100644 --- a/config-model/src/test/java/com/yahoo/config/model/MockModelContext.java +++ b/config-model/src/test/java/com/yahoo/config/model/MockModelContext.java @@ -2,19 +2,23 @@ package com.yahoo.config.model; import com.yahoo.component.Version; -import com.yahoo.config.model.api.*; import com.yahoo.config.application.api.ApplicationPackage; -import com.yahoo.config.model.application.provider.BaseDeployLogger; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.config.application.api.FileRegistry; +import com.yahoo.config.model.api.ConfigDefinitionRepo; +import com.yahoo.config.model.api.ConfigServerSpec; +import com.yahoo.config.model.api.HostProvisioner; +import com.yahoo.config.model.api.Model; +import com.yahoo.config.model.api.ModelContext; +import com.yahoo.config.model.application.provider.BaseDeployLogger; import com.yahoo.config.model.application.provider.MockFileRegistry; import com.yahoo.config.model.application.provider.StaticConfigDefinitionRepo; import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.Rotation; import com.yahoo.config.provision.Zone; -import java.net.URI; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -96,7 +100,7 @@ public class MockModelContext implements ModelContext { } @Override - public URI loadBalancerAddress() { + public HostName loadBalancerName() { return null; } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/VespaModelFactoryTest.java b/config-model/src/test/java/com/yahoo/vespa/model/VespaModelFactoryTest.java index 873883716e4..9a507827d17 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/VespaModelFactoryTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/VespaModelFactoryTest.java @@ -18,6 +18,7 @@ import com.yahoo.config.provision.ApplicationName; import com.yahoo.config.provision.Capacity; import com.yahoo.config.provision.ClusterMembership; import com.yahoo.config.provision.ClusterSpec; +import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.HostSpec; import com.yahoo.config.provision.InstanceName; import com.yahoo.config.provision.ProvisionLogger; @@ -27,7 +28,6 @@ import com.yahoo.config.provision.Zone; import org.junit.Before; import org.junit.Test; -import java.net.URI; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -196,7 +196,7 @@ public class VespaModelFactoryTest { } @Override - public URI loadBalancerAddress() { + public HostName loadBalancerName() { return null; } }; |