summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2019-10-04 14:29:59 +0200
committerJon Marius Venstad <venstad@gmail.com>2019-10-04 14:29:59 +0200
commit9e9db6e708acd28f7483989ad6c8996ffd80fef5 (patch)
treec1ea5d0484fe719ac30649f795bc85e8798c1d6b
parent0b49f5f4c62b271bae7dd76830eb6325161d312a (diff)
List content clusters also for application/v4 test-config responses
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java9
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java10
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java12
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java5
-rw-r--r--hosted-api/src/main/java/ai/vespa/hosted/api/TestConfig.java2
5 files changed, 23 insertions, 15 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java
index 34ec38e8c48..bfe7fc1ee2e 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java
@@ -2,6 +2,7 @@
package com.yahoo.vespa.hosted.controller;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
import com.yahoo.component.Version;
import com.yahoo.config.application.api.DeploymentSpec;
import com.yahoo.config.application.api.ValidationId;
@@ -212,6 +213,14 @@ public class ApplicationController {
public ApplicationStore applicationStore() { return applicationStore; }
+ /** Returns all content clusters in all current deployments of the given application. */
+ public Map<ZoneId, List<String>> listClusters(ApplicationId id, Iterable<ZoneId> zones) {
+ ImmutableMap.Builder<ZoneId, List<String>> clusters = ImmutableMap.builder();
+ for (ZoneId zone : zones)
+ clusters.put(zone, ImmutableList.copyOf(configServer.getContentClusters(new DeploymentId(id, zone))));
+ return clusters.build();
+ }
+
/** Returns the oldest Vespa version installed on any active or reserved production node for the given application. */
public Version oldestInstalledPlatform(TenantAndApplicationId id) {
return requireApplication(id).instances().values().stream()
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java
index 1828a189cad..42e270edd5e 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java
@@ -468,7 +468,7 @@ public class InternalStepRunner implements StepRunner {
testConfigSerializer.configJson(id.application(),
id.type(),
endpoints,
- listClusters(id.application(), zones)));
+ controller.applications().listClusters(id.application(), zones)));
return Optional.of(running);
}
@@ -690,14 +690,6 @@ public class InternalStepRunner implements StepRunner {
throw new IllegalStateException("No step deploys to the zone this run is for!");
}
- /** Returns all content clusters in all current deployments of the given real application. */
- private Map<ZoneId, List<String>> listClusters(ApplicationId id, Iterable<ZoneId> zones) {
- ImmutableMap.Builder<ZoneId, List<String>> clusters = ImmutableMap.builder();
- for (ZoneId zone : zones)
- clusters.put(zone, ImmutableList.copyOf(controller.serviceRegistry().configServer().getContentClusters(new DeploymentId(id, zone))));
- return clusters.build();
- }
-
/** Returns the generated services.xml content for the tester application. */
static byte[] servicesXml(AthenzDomain domain, boolean useAthenzCredentials, boolean useTesterCertificate,
NodeResources resources) {
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 8b1025cd9b7..b76d0ae1094 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
@@ -133,6 +133,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
private final Controller controller;
private final AccessControlRequests accessControlRequests;
+ private final TestConfigSerializer testConfigSerializer;
@Inject
public ApplicationApiHandler(LoggingRequestHandler.Context parentCtx,
@@ -141,6 +142,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
super(parentCtx);
this.controller = controller;
this.accessControlRequests = accessControlRequests;
+ this.testConfigSerializer = new TestConfigSerializer(controller.system());
}
@Override
@@ -1315,11 +1317,11 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
}
private HttpResponse testConfig(ApplicationId id, JobType type) {
- var endpoints = controller.applications().clusterEndpoints(id, controller.jobController().testedZoneAndProductionZones(id, type));
- return new SlimeJsonResponse(new TestConfigSerializer(controller.system()).configSlime(id,
- type,
- endpoints,
- Collections.emptyMap()));
+ Set<ZoneId> zones = controller.jobController().testedZoneAndProductionZones(id, type);
+ return new SlimeJsonResponse(testConfigSerializer.configSlime(id,
+ type,
+ controller.applications().clusterEndpoints(id, zones),
+ controller.applications().listClusters(id, zones)));
}
private static DeploymentJobs.JobReport toJobReport(String tenantName, String applicationName, Inspector report) {
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 a415f09f54c..7cacd91a5c4 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
@@ -549,6 +549,11 @@ public class ApplicationApiTest extends ControllerContainerTest {
.oktaAccessToken(OKTA_AT),
new File("delete-with-active-deployments.json"), 400);
+ // GET test-config for local tests against a prod deployment
+ tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/instance/instance1/job/production-us-central-1/test-config", GET)
+ .userIdentity(USER_ID),
+ new File("test-config.json"));
+
// DELETE (deactivate) a deployment - dev
tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/dev/region/us-west-1/instance/instance1", DELETE)
.userIdentity(USER_ID),
diff --git a/hosted-api/src/main/java/ai/vespa/hosted/api/TestConfig.java b/hosted-api/src/main/java/ai/vespa/hosted/api/TestConfig.java
index b8698eab15f..c0a18121f43 100644
--- a/hosted-api/src/main/java/ai/vespa/hosted/api/TestConfig.java
+++ b/hosted-api/src/main/java/ai/vespa/hosted/api/TestConfig.java
@@ -41,7 +41,7 @@ public class TestConfig {
/**
* Parses the given test config JSON and returns a new config instance.
*
- * If the given JSON has a "clusters" element, a config object with default values
+ * If the given JSON has a "localEndpoints" element, a config object with default values
* is returned, using {@link #fromEndpointsOnly}. Otherwise, all config attributes are parsed.
*/
public static TestConfig fromJson(byte[] jsonBytes) {