summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-09-26 09:06:03 -0700
committerGitHub <noreply@github.com>2018-09-26 09:06:03 -0700
commit24e8e9b795a1ab7454977792a56cb9704f182dba (patch)
tree2ae8b2ba7a4cbe9fd71fefd7c28b18b501111e28
parent07f06a4eaf43254c933d42712c14dd4533f8e2a8 (diff)
parent1e60423adf1372318529647ebfc6d37a9400ddb0 (diff)
Merge pull request #7098 from vespa-engine/frodelu/combined-api-uris
Adding getConfigServerApiUris() to include both cfg servers and VIP [VESPA-12701]
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneRegistry.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/integration/ConfigServerMock.java8
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneRegistryMock.java13
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/services.json4
5 files changed, 24 insertions, 8 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneRegistry.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneRegistry.java
index e7ef3e52eb5..f35c5b1c310 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneRegistry.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneRegistry.java
@@ -34,6 +34,9 @@ public interface ZoneRegistry {
/** Returns the URI for the config server VIP in the given zone, or Optional.empty() if no VIP exists */
default Optional<URI> getConfigServerVipUri(ZoneId zoneId) { return Optional.empty(); }
+ /** Returns all possible API endpoints of all known config servers and config server VIPs in the given zone */
+ List<URI> getConfigServerApiUris(ZoneId zoneId);
+
/** Returns a URL with the logs for the given deployment, if logging is configured for its zone */
Optional<URI> getLogServerUri(DeploymentId deploymentId);
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 808bb2e716a..8b2263fffdc 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
@@ -639,7 +639,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
ApplicationView applicationView = controller.getApplicationView(tenantName, applicationName, instanceName, environment, region);
ServiceApiResponse response = new ServiceApiResponse(ZoneId.from(environment, region),
new ApplicationId.Builder().tenant(tenantName).applicationName(applicationName).instanceName(instanceName).build(),
- controller.zoneRegistry().getConfigServerUris(ZoneId.from(environment, region)),
+ controller.zoneRegistry().getConfigServerApiUris(ZoneId.from(environment, region)),
request.getUri());
response.setResponse(applicationView);
return response;
@@ -649,7 +649,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
Map<?,?> result = controller.getServiceApiResponse(tenantName, applicationName, instanceName, environment, region, serviceName, restPath);
ServiceApiResponse response = new ServiceApiResponse(ZoneId.from(environment, region),
new ApplicationId.Builder().tenant(tenantName).applicationName(applicationName).instanceName(instanceName).build(),
- controller.zoneRegistry().getConfigServerUris(ZoneId.from(environment, region)),
+ controller.zoneRegistry().getConfigServerApiUris(ZoneId.from(environment, region)),
request.getUri());
response.setResponse(result, serviceName, restPath);
return response;
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java
index b0b3b352726..fcb2f4a973d 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java
@@ -252,17 +252,21 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer
@Override
public ApplicationView getApplicationView(String tenantName, String applicationName, String instanceName,
String environment, String region) {
+ String cfgHostname = String.format("https://cfg.%s.%s.test.vip:4443", environment, region);
+ String cfgServiceUrlPrefix = String.format("%s/serviceview/v1/tenant/%s/application/%s/environment/%s/region/%s/instance/%s/service",
+ cfgHostname, tenantName, applicationName,
+ environment, region, instanceName);
ApplicationView applicationView = new ApplicationView();
ClusterView cluster = new ClusterView();
cluster.name = "cluster1";
cluster.type = "content";
- cluster.url = "http://localhost:8080/application/v4/tenant/tenant1/application/application1/environment/prod/region/us-west-1/instance/default/service/container-clustercontroller-6s8slgtps7ry8uh6lx21ejjiv/cluster/v2/cluster1";
+ cluster.url = cfgServiceUrlPrefix + "/container-clustercontroller-6s8slgtps7ry8uh6lx21ejjiv/cluster/v2/cluster1";
ServiceView service = new ServiceView();
service.configId = "cluster1/storage/0";
service.host = "host1";
service.serviceName = "storagenode";
service.serviceType = "storagenode";
- service.url = "http://localhost:8080/application/v4/tenant/tenant1/application/application1/environment/prod/region/us-west-1/instance/default/service/storagenode-awe3slno6mmq2fye191y324jl/state/v1/";
+ service.url = cfgServiceUrlPrefix + "/storagenode-awe3slno6mmq2fye191y324jl/state/v1/";
cluster.services = new ArrayList<>();
cluster.services.add(service);
applicationView.clusters = new ArrayList<>();
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneRegistryMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneRegistryMock.java
index cb6d971c2d9..ad6c26322da 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneRegistryMock.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneRegistryMock.java
@@ -117,12 +117,21 @@ public class ZoneRegistryMock extends AbstractComponent implements ZoneRegistry
@Override
public List<URI> getConfigServerUris(ZoneId zoneId) {
- return Collections.singletonList(URI.create(String.format("https://cfg.%s.test:4443", zoneId.value())));
+ return Collections.singletonList(URI.create(String.format("https://cfg.%s.test:4443/", zoneId.value())));
}
@Override
public Optional<URI> getConfigServerVipUri(ZoneId zoneId) {
- return Optional.of(URI.create(String.format("https://cfg.%s.test:4443", zoneId.value())));
+ return Optional.of(URI.create(String.format("https://cfg.%s.test.vip:4443/", zoneId.value())));
+ }
+
+ @Override
+ public List<URI> getConfigServerApiUris(ZoneId zoneId) {
+ List<URI> uris = new ArrayList<URI>();
+ uris.add(URI.create(String.format("https://cfg.%s.test:4443/", zoneId.value())));
+ uris.add(URI.create(String.format("https://cfg.%s.test.vip:4443/", zoneId.value())));
+
+ return uris;
}
@Override
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/services.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/services.json
index 8a0849393c9..c68b7dc9e87 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/services.json
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/services.json
@@ -3,10 +3,10 @@
{
"name": "cluster1",
"type": "content",
- "url": "http://localhost:8080/application/v4/tenant/tenant1/application/application1/environment/prod/region/us-west-1/instance/default/service/container-clustercontroller-6s8slgtps7ry8uh6lx21ejjiv/cluster/v2/cluster1",
+ "url": "http://localhost:8080/application/v4/tenant/tenant1/application/application1/environment/prod/region/corp-us-east-1/instance/default/service/container-clustercontroller-6s8slgtps7ry8uh6lx21ejjiv/cluster/v2/cluster1",
"services": [
{
- "url": "http://localhost:8080/application/v4/tenant/tenant1/application/application1/environment/prod/region/us-west-1/instance/default/service/storagenode-awe3slno6mmq2fye191y324jl/state/v1/",
+ "url": "http://localhost:8080/application/v4/tenant/tenant1/application/application1/environment/prod/region/corp-us-east-1/instance/default/service/storagenode-awe3slno6mmq2fye191y324jl/state/v1/",
"serviceType": "storagenode",
"serviceName": "storagenode",
"configId": "cluster1/storage/0",