diff options
author | Harald Musum <musum@verizonmedia.com> | 2020-08-03 20:38:51 +0200 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2020-08-03 20:38:51 +0200 |
commit | 59155208864186e25bdadfa7f14044c5a19f8a37 (patch) | |
tree | d4cba077df10dda773d71da51cd496fc96fa4fa7 /configserver | |
parent | b01035f3ac8e1986f3e6053611757830978a660e (diff) |
Fallback to default application id only for default tenant
Diffstat (limited to 'configserver')
3 files changed, 7 insertions, 7 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java index 5567de6dadc..ba3b6f71b4b 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java @@ -395,11 +395,7 @@ public class TenantApplications implements RequestHandler, HostValidator<Applica @Override public ApplicationId resolveApplicationId(String hostName) { - ApplicationId applicationId = hostRegistry.getKeyForHost(hostName); - if (applicationId == null) { - applicationId = ApplicationId.defaultId(); - } - return applicationId; + return hostRegistry.getKeyForHost(hostName); } @Override diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java index a6c12f49a8e..388ddb4048c 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java @@ -392,7 +392,8 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener { if ("*".equals(request.getConfigKey().getConfigId())) { return GetConfigContext.create(ApplicationId.global(), superModelRequestHandler, trace); } - TenantName tenant = optionalTenant.orElse(TenantName.defaultName()); // perhaps needed for non-hosted? + // TODO: Look into if this fallback really is needed + TenantName tenant = optionalTenant.orElse(TenantName.defaultName()); Optional<RequestHandler> requestHandler = getRequestHandler(tenant); if (requestHandler.isEmpty()) { String msg = TenantRepository.logPre(tenant) + "Unable to find request handler for tenant '" + tenant + @@ -404,6 +405,9 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener { } RequestHandler handler = requestHandler.get(); ApplicationId applicationId = handler.resolveApplicationId(request.getClientHostName()); + // TODO: Look into if this fallback really is needed + if (applicationId == null && tenant.equals(TenantName.defaultName())) + applicationId = ApplicationId.defaultId(); if (trace.shouldTrace(TRACELEVEL_DEBUG)) { trace.trace(TRACELEVEL_DEBUG, "Host '" + request.getClientHostName() + "' should have config from application '" + applicationId + "'"); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java index 6f60b0255b8..50a8cac2837 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java @@ -600,7 +600,7 @@ public class ApplicationRepositoryTest { assertEquals(1330, config2.intval()); assertTrue(requestHandler.hasApplication(applicationId(), Optional.of(vespaVersion))); - assertThat(requestHandler.resolveApplicationId("doesnotexist"), Is.is(ApplicationId.defaultId())); + assertNull(requestHandler.resolveApplicationId("doesnotexist")); assertThat(requestHandler.resolveApplicationId("mytesthost"), Is.is(new ApplicationId.Builder() .tenant(tenant1) .applicationName("testapp").build())); // Host set in application package. |