summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/ZoneRegistry.java7
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/proxy/ConfigServerRestExecutorImpl.java18
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneRegistryMock.java9
3 files changed, 11 insertions, 23 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 d808b4b7adb..72f9f5b7ce2 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
@@ -39,8 +39,8 @@ public interface ZoneRegistry {
/** Returns the API endpoints of all known config servers in the given zone */
List<URI> getConfigServerUris(ZoneId zoneId);
- /** Returns the URI for the config server VIP in the given zone */
- URI getConfigServerVipUri(ZoneId zoneId);
+ /** 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);
@@ -87,7 +87,4 @@ public interface ZoneRegistry {
/** Returns a URL used to generate flashy badges from strings. */
URI badgeUrl();
- /** Returns a URL to the controller's api endpoint */
- URI apiUrl();
-
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/proxy/ConfigServerRestExecutorImpl.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/proxy/ConfigServerRestExecutorImpl.java
index 72b11f56d9f..a4ca8605f4b 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/proxy/ConfigServerRestExecutorImpl.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/proxy/ConfigServerRestExecutorImpl.java
@@ -79,7 +79,13 @@ public class ConfigServerRestExecutorImpl implements ConfigServerRestExecutor {
ZoneId zoneId = ZoneId.from(proxyRequest.getEnvironment(), proxyRequest.getRegion());
- List<URI> allServers = getConfigserverEndpoints(zoneId);
+ // Make a local copy of the list as we want to manipulate it in case of ping problems.
+ List<URI> allServers = zoneRegistry.getConfigServerVipUri(zoneId)
+ // TODO: Use config server VIP for all zones that have one
+ .filter(zone -> zoneId.region().value().startsWith("aws-") || zoneId.region().value().contains("-aws-"))
+
+ .map(Collections::singletonList)
+ .orElseGet(() -> new ArrayList<>(zoneRegistry.getConfigServerUris(zoneId)));
StringBuilder errorBuilder = new StringBuilder();
if (queueFirstServerIfDown(allServers, proxyRequest)) {
@@ -96,16 +102,6 @@ public class ConfigServerRestExecutorImpl implements ConfigServerRestExecutor {
+ errorBuilder.toString()));
}
- private List<URI> getConfigserverEndpoints(ZoneId zoneId) {
- // TODO: Use config server VIP for all zones that have one
- // Make a local copy of the list as we want to manipulate it in case of ping problems.
- if (zoneId.region().value().startsWith("aws-") || zoneId.region().value().contains("-aws-")) {
- return Collections.singletonList(zoneRegistry.getConfigServerVipUri(zoneId));
- } else {
- return new ArrayList<>(zoneRegistry.getConfigServerUris(zoneId));
- }
- }
-
private static class DiscoveryResponseStructure {
public List<String> uris = 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 32bbf3ceb9b..7771dd2d1a0 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
@@ -165,11 +165,6 @@ public class ZoneRegistryMock extends AbstractComponent implements ZoneRegistry
}
@Override
- public URI apiUrl() {
- return URI.create("https://api.tld:4443/");
- }
-
- @Override
public boolean hasZone(ZoneId zoneId) {
return zones.stream().anyMatch(zone -> zone.getId().equals(zoneId));
}
@@ -180,8 +175,8 @@ public class ZoneRegistryMock extends AbstractComponent implements ZoneRegistry
}
@Override
- public URI getConfigServerVipUri(ZoneId zoneId) {
- return URI.create(String.format("https://cfg.%s.test.vip:4443/", zoneId.value()));
+ public Optional<URI> getConfigServerVipUri(ZoneId zoneId) {
+ return Optional.of(URI.create(String.format("https://cfg.%s.test.vip:4443/", zoneId.value())));
}
@Override