diff options
7 files changed, 16 insertions, 7 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 92c0a6b1fbb..6a751188599 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 @@ -56,7 +56,7 @@ public interface ZoneRegistry { ZoneApi get(ZoneId zoneId); /** Returns the URI for the config server VIP in the given zone */ - URI getConfigServerVipUri(ZoneId zoneId); + URI getConfigServerVipUri(ZoneId zoneId, boolean publiclyReachable); /** Returns the VIP hostname for the shared routing layer in given zone, if any */ Optional<String> getVipHostname(ZoneId zoneId); diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/FlagsTarget.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/FlagsTarget.java index 051ddb3d8ea..bc2700bc6a2 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/FlagsTarget.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/FlagsTarget.java @@ -70,7 +70,7 @@ public interface FlagsTarget { return new ConfigServerFlagsTarget(registry.system(), zone.getCloudName(), zone.getVirtualId(), - registry.getConfigServerVipUri(zone.getVirtualId()), + registry.getConfigServerVipUri(zone.getVirtualId(), zone.getCloudName().equals(CloudName.AWS)), registry.getConfigServerHttpsIdentity(zone.getVirtualId())); } diff --git a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/SystemFlagsDataArchiveTest.java b/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/SystemFlagsDataArchiveTest.java index df487f789cf..352cf820894 100644 --- a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/SystemFlagsDataArchiveTest.java +++ b/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/SystemFlagsDataArchiveTest.java @@ -41,6 +41,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -429,7 +430,7 @@ public class SystemFlagsDataArchiveTest { when(zoneApi.getCloudName()).thenReturn(CloudName.YAHOO); when(zoneApi.getVirtualId()).thenReturn(ZoneId.ofVirtualControllerZone()); when(registryMock.systemZone()).thenReturn(zoneApi); - when(registryMock.getConfigServerVipUri(any())).thenReturn(URI.create("http://localhost:8080/")); + when(registryMock.getConfigServerVipUri(any(), anyBoolean())).thenReturn(URI.create("http://localhost:8080/")); when(registryMock.getConfigServerHttpsIdentity(any())).thenReturn(new AthenzService("domain", "servicename")); ZoneList zones = mockZoneList("prod.us-west-1", "prod.us-east-3"); when(registryMock.zones()).thenReturn(zones); 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 bbed0554350..ba8dddc889a 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 @@ -4,6 +4,8 @@ package com.yahoo.vespa.hosted.controller.proxy; import ai.vespa.util.http.hc4.SslConnectionSocketFactory; import com.yahoo.component.AbstractComponent; import com.yahoo.component.annotation.Inject; +import com.yahoo.config.provision.CloudName; +import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.jdisc.http.HttpRequest.Method; import com.yahoo.text.Text; import com.yahoo.vespa.athenz.api.AthenzIdentity; @@ -277,7 +279,7 @@ public class ConfigServerRestExecutorImpl extends AbstractComponent implements C public ConnectionReuseStrategy(ZoneRegistry zoneRegistry) { this(zoneRegistry.zones().all().ids().stream() - .map(zoneRegistry::getConfigServerVipUri) + .map((ZoneId zoneId) -> zoneRegistry.getConfigServerVipUri(zoneId, zoneRegistry.systemZone().getCloudName().equals(CloudName.AWS))) .map(URI::getHost) .collect(Collectors.toUnmodifiableSet())); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/configserver/ConfigServerApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/configserver/ConfigServerApiHandler.java index b1e44756802..425c1fd894d 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/configserver/ConfigServerApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/configserver/ConfigServerApiHandler.java @@ -2,6 +2,7 @@ package com.yahoo.vespa.hosted.controller.restapi.configserver; import ai.vespa.http.HttpURL; +import com.yahoo.config.provision.CloudName; import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.config.provision.zone.ZoneList; import com.yahoo.container.jdisc.HttpRequest; @@ -44,12 +45,14 @@ public class ConfigServerApiHandler extends AuditLoggingRequestHandler { private final ZoneRegistry zoneRegistry; private final ConfigServerRestExecutor proxy; private final ZoneId controllerZone; + private final CloudName controllerCloud; public ConfigServerApiHandler(Context parentCtx, ServiceRegistry serviceRegistry, ConfigServerRestExecutor proxy, Controller controller) { super(parentCtx, controller.auditLogger()); this.zoneRegistry = serviceRegistry.zoneRegistry(); this.controllerZone = zoneRegistry.systemZone().getVirtualId(); + this.controllerCloud = zoneRegistry.systemZone().getCloudName(); this.proxy = proxy; } @@ -119,7 +122,8 @@ public class ConfigServerApiHandler extends AuditLoggingRequestHandler { } private URI getEndpoint(ZoneId zoneId) { - return controllerZone.equals(zoneId) ? CONTROLLER_URI : zoneRegistry.getConfigServerVipUri(zoneId); + if (controllerZone.equals(zoneId)) return CONTROLLER_URI; + return zoneRegistry.getConfigServerVipUri(zoneId, controllerCloud.equals(CloudName.AWS)); } } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/zone/v2/ZoneApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/zone/v2/ZoneApiHandler.java index f29845d2476..722bdac2101 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/zone/v2/ZoneApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/zone/v2/ZoneApiHandler.java @@ -2,6 +2,7 @@ package com.yahoo.vespa.hosted.controller.restapi.zone.v2; import ai.vespa.http.HttpURL; +import com.yahoo.config.provision.CloudName; import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.config.provision.zone.ZoneList; import com.yahoo.container.jdisc.HttpRequest; @@ -100,7 +101,8 @@ public class ZoneApiHandler extends AuditLoggingRequestHandler { } private ProxyRequest proxyRequest(ZoneId zoneId, HttpURL.Path path, HttpRequest request) { - return ProxyRequest.tryOne(zoneRegistry.getConfigServerVipUri(zoneId), path, request); + return ProxyRequest.tryOne(zoneRegistry.getConfigServerVipUri(zoneId, zoneRegistry.systemZone().getCloudName().equals(CloudName.AWS)), + path, request); } } 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 c5b11fe21b0..ab1195a91be 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 @@ -244,7 +244,7 @@ public class ZoneRegistryMock extends AbstractComponent implements ZoneRegistry } @Override - public URI getConfigServerVipUri(ZoneId zoneId) { + public URI getConfigServerVipUri(ZoneId zoneId, boolean publiclyReachable) { return URI.create(Text.format("https://cfg.%s.test.vip:4443/", zoneId.value())); } |