diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2022-03-30 14:24:59 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2022-03-30 14:24:59 +0200 |
commit | 06f6b985addf8c8ef5e60a1c3202b4002fdfd959 (patch) | |
tree | 18422de6962d735a92449a0be8f05920c51d8a08 /configserver | |
parent | d9a7ccfb233dd4104dc50f759e5c84f5581a6f71 (diff) |
Wrap in Hostname
Diffstat (limited to 'configserver')
-rw-r--r-- | configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java | 7 | ||||
-rw-r--r-- | configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java | 3 |
2 files changed, 6 insertions, 4 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..4728b80af1f 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 ai.vespa.validation.Hostname; 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<Hostname> 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<Hostname> 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..49c056e7f80 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 ai.vespa.validation.Hostname; 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<Hostname> hostname = Optional.ofNullable(request.getProperty("hostname")).map(Hostname::of); String apiParams = Optional.ofNullable(request.getUri().getQuery()).map(q -> "?" + q).orElse(""); return applicationRepository.getLogs(applicationId, hostname, apiParams); } |