aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2020-03-16 11:05:50 +0100
committerGitHub <noreply@github.com>2020-03-16 11:05:50 +0100
commit2133f64c1d2a80b41a245d0666976c5f2003d53f (patch)
treecff6920f1bc3f020022903d567d81f3aec4d2e27 /controller-server
parentacd8d9298c837a9005f0f54e8da062260d7339cc (diff)
Revert "Remove RoutingGenerator"
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java10
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java25
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java3
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java12
4 files changed, 50 insertions, 0 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java
index 6cfde326c50..1730f033d61 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java
@@ -85,12 +85,22 @@ public class RoutingController {
/** Returns zone-scoped endpoints for given deployment */
public EndpointList endpointsOf(DeploymentId deployment) {
var endpoints = new LinkedHashSet<Endpoint>();
+ // TODO(mpolden): Remove this once all applications have deployed once and config server passes correct cluster
+ // id for combined cluster type
+ controller.serviceRegistry().routingGenerator().clusterEndpoints(deployment)
+ .forEach((cluster, url) -> endpoints.add(Endpoint.of(deployment.applicationId())
+ .target(cluster, deployment.zoneId())
+ .routingMethod(RoutingMethod.shared)
+ .on(Port.fromRoutingMethod(RoutingMethod.shared))
+ .in(controller.system())));
+ boolean hasSharedEndpoint = !endpoints.isEmpty();
// Avoid reading application more than once per call to this
var application = Suppliers.memoize(() -> controller.applications().requireApplication(TenantAndApplicationId.from(deployment.applicationId())));
for (var policy : routingPolicies.get(deployment).values()) {
if (!policy.status().isActive()) continue;
for (var routingMethod : controller.zoneRegistry().routingMethods(policy.id().zone())) {
if (routingMethod.isDirect() && !canRouteDirectlyTo(deployment, application.get())) continue;
+ if (hasSharedEndpoint && routingMethod == RoutingMethod.shared) continue;
endpoints.add(policy.endpointIn(controller.system(), routingMethod));
}
}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java
index a0d2630091b..ad8c7d7c328 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java
@@ -26,6 +26,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationV
import com.yahoo.vespa.hosted.controller.api.integration.dns.Record;
import com.yahoo.vespa.hosted.controller.api.integration.dns.RecordData;
import com.yahoo.vespa.hosted.controller.api.integration.dns.RecordName;
+import com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingEndpoint;
import com.yahoo.vespa.hosted.controller.application.ApplicationPackage;
import com.yahoo.vespa.hosted.controller.application.Deployment;
import com.yahoo.vespa.hosted.controller.application.DeploymentMetrics;
@@ -784,6 +785,30 @@ public class ControllerTest {
}
@Test
+ public void testDeployWithRoutingGeneratorEndpoints() {
+ var context = tester.newDeploymentContext();
+ var applicationPackage = new ApplicationPackageBuilder()
+ .upgradePolicy("default")
+ .environment(Environment.prod)
+ .region("us-west-1")
+ .build();
+
+ var zones = Set.of(systemTest.zone(tester.controller().system()),
+ stagingTest.zone(tester.controller().system()),
+ ZoneId.from("prod", "us-west-1"));
+ for (var zone : zones) {
+ tester.controllerTester().serviceRegistry().routingGeneratorMock()
+ .putEndpoints(context.deploymentIdIn(zone),
+ List.of(new RoutingEndpoint("http://legacy-endpoint", "hostname",
+ false, "upstreamName")));
+ }
+ // Defer load balancer provisioning in all environments so that routing controller uses routing generator
+ context.deferLoadBalancerProvisioningIn(zones.stream().map(ZoneId::environment).collect(Collectors.toSet()))
+ .submit(applicationPackage)
+ .deploy();
+ }
+
+ @Test
public void testDeployWithGlobalEndpointsAndMultipleRoutingMethods() {
var context = tester.newDeploymentContext();
var zone1 = ZoneId.from("prod", "us-west-1");
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java
index c9ad121276f..21b6e729e41 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java
@@ -18,6 +18,7 @@ import com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbi
import com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.RefeedAction;
import com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.RestartAction;
import com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.ServiceInfo;
+import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId;
import com.yahoo.vespa.hosted.controller.api.integration.LogEntry;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerException;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.Node;
@@ -177,6 +178,8 @@ public class InternalStepRunnerTest {
.deferLoadBalancerProvisioningIn(testZone.environment());
tester.newDeploymentContext(app.instanceId())
.deferLoadBalancerProvisioningIn(stagingZone.environment());
+ tester.controllerTester().serviceRegistry().routingGeneratorMock().putEndpoints(new DeploymentId(app.testerId().id(), testZone), List.of());
+ tester.controllerTester().serviceRegistry().routingGeneratorMock().putEndpoints(new DeploymentId(app.instanceId(), stagingZone), List.of());
tester.runner().run();
tester.configServer().convergeServices(app.instanceId(), JobType.stagingTest.zone(system()));
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java
index 98178f2a19f..8863651e1b5 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java
@@ -21,6 +21,8 @@ import com.yahoo.vespa.hosted.controller.api.integration.resource.CostReportCons
import com.yahoo.vespa.hosted.controller.api.integration.resource.MockTenantCost;
import com.yahoo.vespa.hosted.controller.api.integration.routing.GlobalRoutingService;
import com.yahoo.vespa.hosted.controller.api.integration.routing.MemoryGlobalRoutingService;
+import com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingGenerator;
+import com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingGeneratorMock;
import com.yahoo.vespa.hosted.controller.api.integration.stubs.DummyOwnershipIssues;
import com.yahoo.vespa.hosted.controller.api.integration.stubs.LoggingDeploymentIssues;
import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockMailer;
@@ -40,6 +42,7 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg
private final ConfigServerMock configServerMock;
private final MemoryNameService memoryNameService = new MemoryNameService();
private final MemoryGlobalRoutingService memoryGlobalRoutingService = new MemoryGlobalRoutingService();
+ private final RoutingGeneratorMock routingGeneratorMock = new RoutingGeneratorMock();
private final MockMailer mockMailer = new MockMailer();
private final EndpointCertificateMock endpointCertificateMock = new EndpointCertificateMock();
private final MockMeteringClient mockMeteringClient = new MockMeteringClient();
@@ -89,6 +92,11 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg
}
@Override
+ public RoutingGenerator routingGenerator() {
+ return routingGeneratorMock;
+ }
+
+ @Override
public MockMailer mailer() {
return mockMailer;
}
@@ -189,6 +197,10 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg
return memoryGlobalRoutingService;
}
+ public RoutingGeneratorMock routingGeneratorMock() {
+ return routingGeneratorMock;
+ }
+
public MockContactRetriever contactRetrieverMock() {
return mockContactRetriever;
}