diff options
-rw-r--r-- | configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java | 23 | ||||
-rw-r--r-- | configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java | 6 |
2 files changed, 14 insertions, 15 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java index 75b0519032e..6f907088f01 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java @@ -741,22 +741,19 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye } private String getLogServerURI(ApplicationId applicationId, Optional<String> hostname) { - Application application = getApplication(applicationId); - Collection<HostInfo> hostInfos = application.getModel().getHosts(); - - // In ServiceInfo: node-admin does not have - // 1) Correct ports - // 2) logserver - // Assume if hostname is set that this is node-admin hostname - // TODO: Fix and simplify this once the above to problems have been fixed + // Allow to get logs from a given hostname if the application is under the hosted-vespa tenant. + // We make no validation that the hostname is actually allocated to the given application since + // most applications under hosted-vespa are not known to the model and its OK for a user to get + // logs for any host if they are authorized for the hosted-vespa tenant. if (hostname.isPresent()) { - HostInfo logServerHostInfo = hostInfos.stream() - .filter(host -> host.getHostname().equalsIgnoreCase(hostname.get())) - .findFirst().orElseThrow(() -> - new IllegalArgumentException("Host " + hostname.get() + " does not belong to " + applicationId)); - return "http://" + logServerHostInfo.getHostname() + ":8080/logs"; + if (HOSTED_VESPA_TENANT.equals(applicationId.tenant())) + return "http://" + hostname.get() + ":8080/logs"; + else throw new IllegalArgumentException("Only hostname paramater unsupported for application " + applicationId); } + Application application = getApplication(applicationId); + Collection<HostInfo> hostInfos = application.getModel().getHosts(); + HostInfo logServerHostInfo = hostInfos.stream() .filter(host -> host.getServices().stream() .anyMatch(serviceInfo -> serviceInfo.getServiceType().equalsIgnoreCase("logserver"))) 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 3eff6c935a7..9b76c349259 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 @@ -85,6 +85,7 @@ public class ApplicationRepositoryTest { tenantRepository = new TenantRepository(new TestComponentRegistry.Builder() .curator(curator) .build()); + tenantRepository.addTenant(TenantRepository.HOSTED_VESPA_TENANT); tenantRepository.addTenant(tenant1); tenantRepository.addTenant(tenant2); tenantRepository.addTenant(tenant3); @@ -164,8 +165,9 @@ public class ApplicationRepositoryTest { orchestrator, new MockLogRetriever(), clock); - deployApp(testAppLogServerWithContainer); - HttpResponse response = applicationRepository.getLogs(applicationId(), Optional.of("localhost"), ""); + ApplicationId applicationId = ApplicationId.from("hosted-vespa", "tenant-host", "default"); + deployApp(testAppLogServerWithContainer, new PrepareParams.Builder().applicationId(applicationId).build()); + HttpResponse response = applicationRepository.getLogs(applicationId, Optional.of("localhost"), ""); assertEquals(200, response.getStatus()); } |