diff options
author | Jon Marius Venstad <jonmv@users.noreply.github.com> | 2022-03-31 14:16:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-31 14:16:15 +0200 |
commit | 965c1eb15a0f07029289552e8e1616d2fda2b194 (patch) | |
tree | 2fc8716a590a564c2d7e01234a24dfcc9614a078 /configserver | |
parent | 71c2103ae118c0efc705dc1eb5bc89bc9a28b8d9 (diff) | |
parent | f52ebfd454eb7b3c334e03b5c0ab47d4cb753e1f (diff) |
Merge pull request #21893 from vespa-engine/jonmv/misc-3
Jonmv/misc 3
Diffstat (limited to 'configserver')
3 files changed, 8 insertions, 5 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 c475b4c976d..7a754dd84cd 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 @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server; +import com.yahoo.net.DomainName; import com.google.inject.Inject; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.component.Version; @@ -761,7 +762,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye // ---------------- Logs ---------------------------------------------------------------- - public HttpResponse getLogs(ApplicationId applicationId, Optional<String> hostname, String apiParams) { + public HttpResponse getLogs(ApplicationId applicationId, Optional<DomainName> hostname, String apiParams) { String logServerURI = getLogServerURI(applicationId, hostname) + apiParams; return logRetriever.getLogs(logServerURI); } @@ -1128,14 +1129,14 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye } } - private String getLogServerURI(ApplicationId applicationId, Optional<String> hostname) { + private String getLogServerURI(ApplicationId applicationId, Optional<DomainName> hostname) { // 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 it's OK for a user to get // logs for any host if they are authorized for the hosted-vespa tenant. if (hostname.isPresent() && HOSTED_VESPA_TENANT.equals(applicationId.tenant())) { int port = List.of(InfrastructureApplication.CONFIG_SERVER.id(), InfrastructureApplication.CONTROLLER.id()).contains(applicationId) ? 19071 : 8080; - return "http://" + hostname.get() + ":" + port + "/logs"; + return "http://" + hostname.get().value() + ":" + port + "/logs"; } Application application = getApplication(applicationId); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java index df4df234ed0..0707261bb45 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.http.v2; +import com.yahoo.net.DomainName; import com.google.inject.Inject; import com.yahoo.component.Version; import com.yahoo.config.application.api.ApplicationFile; @@ -156,7 +157,7 @@ public class ApplicationHandler extends HttpHandler { } private HttpResponse logs(ApplicationId applicationId, HttpRequest request) { - Optional<String> hostname = Optional.ofNullable(request.getProperty("hostname")); + Optional<DomainName> hostname = Optional.ofNullable(request.getProperty("hostname")).map(DomainName::of); String apiParams = Optional.ofNullable(request.getUri().getQuery()).map(q -> "?" + q).orElse(""); return applicationRepository.getLogs(applicationId, hostname, apiParams); } 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 5804fcb8ad5..e3fc2345c68 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 @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server; +import com.yahoo.net.DomainName; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.component.Version; import com.yahoo.config.ConfigInstance; @@ -253,7 +254,7 @@ public class ApplicationRepositoryTest { public void getLogsForHostname() { 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"), ""); + HttpResponse response = applicationRepository.getLogs(applicationId, Optional.of(DomainName.localhost), ""); assertEquals(200, response.getStatus()); } |