summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorMorten Tokle <mortent@verizonmedia.com>2020-02-21 09:42:02 +0100
committerGitHub <noreply@github.com>2020-02-21 09:42:02 +0100
commit25bcc44fcf22a5e4737d6d4551b4a292bc04d4e0 (patch)
treed36a2ca6cb88797d20327353e8cb79ad4eec2d3e /controller-server
parentf4fcb9465c3a3191b1d41531c93f29cae878c2da (diff)
parent66a76e571daff7d877021be0c5356e289e8da810 (diff)
Merge pull request #12295 from vespa-engine/mpolden/remove-invalid-endpoints
Only list routing policy endpoints of exclusively routed zones
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java3
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java4
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java12
3 files changed, 15 insertions, 4 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 74304f2e49d..cf272d94dcd 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
@@ -237,7 +237,8 @@ public class RoutingController {
}
}
- private boolean supportsRoutingMethod(RoutingMethod routingMethod, ZoneId zone) {
+ /** Returns whether given routingMethod is supported by zone */
+ public boolean supportsRoutingMethod(RoutingMethod routingMethod, ZoneId zone) {
return controller.zoneRegistry().zones().routingMethod(routingMethod).ids().contains(zone);
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
index 073306719f3..94d7b120406 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
@@ -1061,6 +1061,9 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
// Add zone endpoints defined by routing policies
var endpointArray = response.setArray("endpoints");
for (var policy : controller.routingController().policies().get(deploymentId).values()) {
+ // TODO(mpolden): Always add endpoints from all policies, independent of routing method. This allows removal
+ // of RoutingGenerator and eliminates the external call to the routing layer below.
+ if (!controller.routingController().supportsRoutingMethod(RoutingMethod.exclusive, deployment.zone())) continue;
if (!policy.status().isActive()) continue;
{
var endpointObject = endpointArray.addObject();
@@ -1157,6 +1160,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
deployment.activity().lastWritesPerSecond().ifPresent(value -> activity.setDouble("lastWritesPerSecond", value));
// Cost
+ // TODO(mpolden): Unused, remove this field and related code.
DeploymentCost appCost = new DeploymentCost(Map.of());
Cursor costObject = response.setObject("cost");
toSlime(appCost, costObject);
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java
index 88faf54ea28..442770ba23e 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java
@@ -13,6 +13,7 @@ import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.Environment;
import com.yahoo.config.provision.RegionName;
import com.yahoo.config.provision.TenantName;
+import com.yahoo.config.provision.zone.RoutingMethod;
import com.yahoo.config.provision.zone.ZoneId;
import com.yahoo.vespa.athenz.api.AthenzDomain;
import com.yahoo.vespa.athenz.api.AthenzIdentity;
@@ -58,6 +59,7 @@ import com.yahoo.vespa.hosted.controller.deployment.DeploymentContext;
import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester;
import com.yahoo.vespa.hosted.controller.deployment.DeploymentTrigger;
import com.yahoo.vespa.hosted.controller.integration.ConfigServerMock;
+import com.yahoo.vespa.hosted.controller.integration.ZoneApiMock;
import com.yahoo.vespa.hosted.controller.maintenance.JobControl;
import com.yahoo.vespa.hosted.controller.maintenance.RotationStatusUpdater;
import com.yahoo.vespa.hosted.controller.metric.ApplicationMetrics;
@@ -82,6 +84,7 @@ import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Collections;
+import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -1475,14 +1478,17 @@ public class ApplicationApiTest extends ControllerContainerTest {
@Test
public void applicationWithRoutingPolicy() {
var app = deploymentTester.newDeploymentContext(createTenantAndApplication());
+ var zone = ZoneId.from(Environment.prod, RegionName.from("us-west-1"));
+ deploymentTester.controllerTester().zoneRegistry().setRoutingMethod(ZoneApiMock.from(zone),
+ EnumSet.of(RoutingMethod.exclusive, RoutingMethod.shared));
ApplicationPackage applicationPackage = new ApplicationPackageBuilder()
.environment(Environment.prod)
.instances("instance1")
- .region("us-west-1")
+ .region(zone.region().value())
.build();
app.submit(applicationPackage).deploy();
- app.addRoutingPolicy(ZoneId.from(Environment.prod, RegionName.from("us-west-1")), true);
- app.addRoutingPolicy(ZoneId.from(Environment.prod, RegionName.from("us-west-1")), false);
+ app.addRoutingPolicy(zone, true);
+ app.addRoutingPolicy(zone, false);
// GET application
tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/instance/instance1", GET)