summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2022-02-10 10:38:28 +0100
committerMartin Polden <mpolden@mpolden.no>2022-02-10 10:38:28 +0100
commita4c0cbf1d44b197616fde4b6ec08f259527f8c0c (patch)
treec618b1e37b5053471c0004a78441f5263c9737ba /configserver
parent0b284f194c0b2dc9b1f8b36b489911f32961d840 (diff)
Remove unused fields from LbServicesConfig
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/model/LbServicesProducer.java43
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java27
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java33
3 files changed, 4 insertions, 99 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/model/LbServicesProducer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/model/LbServicesProducer.java
index 69bef89056d..7677417f1a9 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/model/LbServicesProducer.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/model/LbServicesProducer.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.model;
-import com.google.common.base.Joiner;
import com.yahoo.cloud.config.LbServicesConfig;
import com.yahoo.config.model.api.ApplicationClusterEndpoint;
import com.yahoo.config.model.api.ApplicationClusterInfo;
@@ -11,19 +10,14 @@ import com.yahoo.config.model.api.ServiceInfo;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.TenantName;
import com.yahoo.config.provision.Zone;
-import com.yahoo.vespa.flags.BooleanFlag;
-import com.yahoo.vespa.flags.FetchVector;
import com.yahoo.vespa.flags.FlagSource;
-import com.yahoo.vespa.flags.Flags;
-import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
import static com.yahoo.config.model.api.container.ContainerServiceType.CONTAINER;
import static com.yahoo.config.model.api.container.ContainerServiceType.QRSERVER;
@@ -74,13 +68,6 @@ public class LbServicesProducer implements LbServicesConfig.Producer {
// TODO: read active rotation from ApplicationClusterInfo
ab.activeRotation(getActiveRotation(app));
- ab.usePowerOfTwoChoicesLb(true);
- ab.generateNonMtlsEndpoint(false);
-
- // TODO: Remove when endpoints-config is read by all load balancers
- app.getModel().getHosts().stream()
- .sorted((a, b) -> a.getHostname().compareTo(b.getHostname()))
- .forEach(hostInfo -> ab.hosts(hostInfo.getHostname(), getHostsConfig(hostInfo)));
Set<ApplicationClusterInfo> applicationClusterInfos = app.getModel().applicationClusterInfo();
List<LbServicesConfig.Tenants.Applications.Endpoints.Builder> endpointBuilder = applicationClusterInfos.stream()
@@ -121,34 +108,4 @@ public class LbServicesProducer implements LbServicesConfig.Producer {
return activeRotation;
}
- private LbServicesConfig.Tenants.Applications.Hosts.Builder getHostsConfig(HostInfo hostInfo) {
- LbServicesConfig.Tenants.Applications.Hosts.Builder hb = new LbServicesConfig.Tenants.Applications.Hosts.Builder();
- hb.hostname(hostInfo.getHostname());
- hostInfo.getServices().forEach(serviceInfo -> hb.services(serviceInfo.getServiceName(), getServiceConfig(serviceInfo)));
- return hb;
- }
-
- private LbServicesConfig.Tenants.Applications.Hosts.Services.Builder getServiceConfig(ServiceInfo serviceInfo) {
- List<String> endpointAliases = Stream.of(serviceInfo.getProperty("endpointaliases").orElse("").split(",")).
- filter(prop -> !"".equals(prop)).collect(Collectors.toList());
- endpointAliases.addAll(Stream.of(serviceInfo.getProperty("rotations").orElse("").split(",")).filter(prop -> !"".equals(prop)).collect(Collectors.toList()));
- Collections.sort(endpointAliases);
-
- LbServicesConfig.Tenants.Applications.Hosts.Services.Builder sb = new LbServicesConfig.Tenants.Applications.Hosts.Services.Builder()
- .type(serviceInfo.getServiceType())
- .clustertype(serviceInfo.getProperty("clustertype").orElse(""))
- .clustername(serviceInfo.getProperty("clustername").orElse(""))
- .configId(serviceInfo.getConfigId())
- .servicealiases(Stream.of(serviceInfo.getProperty("servicealiases").orElse("").split(",")).
- filter(prop -> !"".equals(prop)).sorted((a, b) -> a.compareTo(b)).collect(Collectors.toList()))
- .endpointaliases(endpointAliases)
- .index(Integer.parseInt(serviceInfo.getProperty("index").orElse("999999")));
- serviceInfo.getPorts().forEach(portInfo -> {
- LbServicesConfig.Tenants.Applications.Hosts.Services.Ports.Builder pb = new LbServicesConfig.Tenants.Applications.Hosts.Services.Ports.Builder()
- .number(portInfo.getPort())
- .tags(Joiner.on(" ").join(portInfo.getTags()));
- sb.ports(pb);
- });
- return sb;
- }
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java
index 2c738e2d519..57060e10282 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java
@@ -13,9 +13,9 @@ import com.yahoo.config.provision.ApplicationName;
import com.yahoo.config.provision.InstanceName;
import com.yahoo.config.provision.TenantName;
import com.yahoo.config.provision.Zone;
-import com.yahoo.vespa.config.PayloadChecksums;
import com.yahoo.jrt.Request;
import com.yahoo.vespa.config.ConfigKey;
+import com.yahoo.vespa.config.PayloadChecksums;
import com.yahoo.vespa.config.protocol.CompressionType;
import com.yahoo.vespa.config.protocol.DefContent;
import com.yahoo.vespa.config.protocol.JRTServerConfigRequestV3;
@@ -35,10 +35,9 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
-import static com.yahoo.config.model.api.container.ContainerServiceType.QRSERVER;
import static com.yahoo.vespa.config.protocol.JRTClientConfigRequestV3.createWithParams;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotNull;
/**
* @author Ulf Lilleengen
@@ -67,10 +66,9 @@ public class SuperModelControllerTest {
assertEquals(1, lbc.tenants().size());
assertEquals(1, lbc.tenants("a").applications().size());
Applications app = lbc.tenants("a").applications("foo:prod:default:default");
- assertTrue(app.hosts().size() > 0);
+ assertNotNull(app);
}
-
@Test(expected = UnknownConfigDefinitionException.class)
public void test_unknown_config_definition() {
PayloadChecksums payloadChecksums = PayloadChecksums.empty();
@@ -107,31 +105,12 @@ public class SuperModelControllerTest {
assertEquals(2, lbc.tenants().size());
assertEquals(2, lbc.tenants("t1").applications().size());
assertEquals(1, lbc.tenants("t2").applications().size());
- assertEquals(1, lbc.tenants("t2").applications("minetooadvancedapp:prod:default:default").hosts().size());
- assertQrServer(lbc.tenants("t2").applications("minetooadvancedapp:prod:default:default"));
}
private ApplicationId applicationId(String applicationName, TenantName tenantName) {
return ApplicationId.from(tenantName, ApplicationName.from(applicationName), InstanceName.defaultName());
}
- private void assertQrServer(Applications app) {
- String host = app.hosts().keySet().iterator().next();
- Applications.Hosts hosts = app.hosts(host);
- assertEquals(host, hosts.hostname());
- for (Map.Entry<String, Applications.Hosts.Services> e : app.hosts(host).services().entrySet()) {
- if (QRSERVER.serviceName.equals(e.getKey())) {
- Applications.Hosts.Services s = e.getValue();
- assertEquals("qrserver", s.type());
- assertEquals(4, s.ports().size());
- assertEquals(8000, s.ports().get(0).number());
- assertEquals(0, s.index());
- return;
- }
- }
- org.junit.Assert.fail("No container service in config");
- }
-
private DeployState createDeployState(File applicationPackage, ApplicationId applicationId) {
return new DeployState.Builder()
.applicationPackage(FilesApplicationPackage.fromFile(applicationPackage))
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java
index 1e37e382247..e64844a612f 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java
@@ -19,7 +19,6 @@ import com.yahoo.config.provision.RegionName;
import com.yahoo.config.provision.TenantName;
import com.yahoo.config.provision.Zone;
import com.yahoo.vespa.config.ConfigPayload;
-import com.yahoo.vespa.flags.Flags;
import com.yahoo.vespa.flags.InMemoryFlagSource;
import com.yahoo.vespa.model.VespaModel;
import org.junit.Test;
@@ -43,7 +42,6 @@ import static com.yahoo.cloud.config.LbServicesConfig.Tenants.Applications.Endpo
import static com.yahoo.cloud.config.LbServicesConfig.Tenants.Applications.Endpoints.Scope.Enum.application;
import static com.yahoo.cloud.config.LbServicesConfig.Tenants.Applications.Endpoints.Scope.Enum.global;
import static com.yahoo.cloud.config.LbServicesConfig.Tenants.Applications.Endpoints.Scope.Enum.zone;
-import static com.yahoo.config.model.api.container.ContainerServiceType.QRSERVER;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
@@ -56,8 +54,6 @@ import static org.junit.Assume.assumeFalse;
@RunWith(Parameterized.class)
public class LbServicesProducerTest {
- private static final String rotation1 = "rotation-1";
- private static final String rotation2 = "rotation-2";
private static final Set<ContainerEndpoint> endpoints = Set.of(
new ContainerEndpoint("mydisc", ApplicationClusterEndpoint.Scope.global, List.of("rotation-1", "rotation-2")),
new ContainerEndpoint("mydisc", ApplicationClusterEndpoint.Scope.application, List.of("app-endpoint"))
@@ -91,20 +87,6 @@ public class LbServicesProducerTest {
}
@Test
- public void testConfigAliases() {
- Map<TenantName, Set<ApplicationInfo>> testModel = createTestModel(new DeployState.Builder());
- LbServicesConfig conf = getLbServicesConfig(Zone.defaultZone(), testModel);
- LbServicesConfig.Tenants.Applications.Hosts.Services services =
- conf.tenants("foo").applications("foo:prod:default:default").hosts("foo.foo.yahoo.com").services(QRSERVER.serviceName);
- assertEquals(1, services.servicealiases().size());
- assertEquals(2, services.endpointaliases().size());
-
- assertEquals("service1", services.servicealiases(0));
- assertEquals("foo1.bar1.com", services.endpointaliases(0));
- assertEquals("foo2.bar2.com", services.endpointaliases(1));
- }
-
- @Test
public void testConfigActiveRotation() {
{
RegionName regionName = RegionName.from("us-east-1");
@@ -141,14 +123,6 @@ public class LbServicesProducerTest {
.properties(new TestProperties().setHostedVespa(true)));
RegionName regionName = RegionName.from("us-east-1");
LbServicesConfig config = getLbServicesConfig(new Zone(Environment.prod, regionName), testModel);
- LbServicesConfig.Tenants.Applications.Hosts.Services services = config
- .tenants("foo")
- .applications("foo:prod:" + regionName.value() + ":default")
- .hosts("foo.foo.yahoo.com")
- .services(QRSERVER.serviceName);
-
- assertTrue(services.servicealiases().contains("service1"));
- assertTrue("Missing endpoints in list: " + services.endpointaliases(), services.endpointaliases().containsAll(List.of("foo1.bar1.com", "foo2.bar2.com", rotation1, rotation2)));
List<Endpoints> endpointList = config.tenants("foo").applications("foo:prod:" + regionName.value() + ":default").endpoints();
// Expect 4 zone endpoints (2 suffixes), 2 global endpoints and 1 application endpoint
@@ -174,16 +148,11 @@ public class LbServicesProducerTest {
assertContainsEndpoint(applicationEndpoints, "app-endpoint", "mydisc", application, sharedLayer4, 1, List.of("foo.foo.yahoo.com"));
}
-
@Test
public void testRoutingConfigForTesterApplication() {
assumeFalse(useGlobalServiceId);
Map<TenantName, Set<ApplicationInfo>> testModel = createTestModel(new DeployState.Builder());
- LbServicesConfig conf = getLbServicesConfig(Zone.defaultZone(), testModel);
- LbServicesConfig.Tenants.Applications.Hosts.Services services = conf.tenants("foo").applications("foo:prod:default:default").hosts("foo.foo.yahoo.com").services(QRSERVER.serviceName);
- assertEquals(1, services.servicealiases().size());
- assertEquals(2, services.endpointaliases().size());
// No config for tester application
assertNull(getLbServicesConfig(Zone.defaultZone(), testModel)
@@ -219,7 +188,7 @@ public class LbServicesProducerTest {
TenantName baz = TenantName.from("baz");
tMap.put(foo, createTestApplications(foo, deployStateBuilder));
tMap.put(bar, createTestApplications(bar, deployStateBuilder));
- tMap.put(bar, createTestApplications(baz, deployStateBuilder));
+ tMap.put(baz, createTestApplications(baz, deployStateBuilder));
return tMap;
}