From ea6e9a69ec3a4363125cab5881ddf2740ee5a7a9 Mon Sep 17 00:00:00 2001 From: Ola Aunrønning Date: Tue, 7 May 2019 14:26:20 +0200 Subject: Remove old log retrieval --- .../api/integration/configserver/ConfigServer.java | 4 +--- .../api/integration/configserver/Logs.java | 17 -------------- .../controller/deployment/InternalStepRunner.java | 2 +- .../restapi/application/ApplicationApiHandler.java | 26 ++++++---------------- .../controller/integration/ConfigServerMock.java | 11 +-------- .../restapi/application/ApplicationApiTest.java | 5 +---- .../restapi/application/responses/logs.json | 4 ---- 7 files changed, 11 insertions(+), 58 deletions(-) delete mode 100644 controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Logs.java delete mode 100644 controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/logs.json diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java index 91a9b5472f5..bcad82a23c1 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java @@ -41,9 +41,7 @@ public interface ConfigServer { Map getServiceApiResponse(String tenantName, String applicationName, String instanceName, String environment, String region, String serviceName, String restPath); - Optional getLogs(DeploymentId deployment, Map queryParameters); - - InputStream getLogStream(DeploymentId deployment, Map queryParameters); + InputStream getLogs(DeploymentId deployment, Map queryParameters); List getContentClusters(DeploymentId deployment); diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Logs.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Logs.java deleted file mode 100644 index ec85fbea35e..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Logs.java +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.configserver; - -import java.util.Map; - -public class Logs { - - private final Map logs; - - public Logs(Map logs) { - this.logs = logs; - } - - public Map logs() { - return this.logs; - } -} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java index d13a9b0e7a0..6de356c36a4 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java @@ -427,7 +427,7 @@ public class InternalStepRunner implements StepRunner { try { logger.log("Copying Vespa log from nodes of " + id.application() + " in " + zone + " ..."); List entries = new ArrayList<>(); - String logs = IOUtils.readAll(controller.configServer().getLogStream(new DeploymentId(id.application(), zone), + String logs = IOUtils.readAll(controller.configServer().getLogs(new DeploymentId(id.application(), zone), Collections.emptyMap()), // Get all logs. StandardCharsets.UTF_8); for (String line : logs.split("\n")) { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java index 5c5ed88d916..16c39a7e601 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java @@ -44,7 +44,6 @@ import com.yahoo.vespa.hosted.controller.api.identifiers.Hostname; import com.yahoo.vespa.hosted.controller.api.identifiers.TenantId; import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerException; import com.yahoo.vespa.hosted.controller.api.integration.configserver.Log; -import com.yahoo.vespa.hosted.controller.api.integration.configserver.Logs; import com.yahoo.vespa.hosted.controller.api.integration.configserver.Node; import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationVersion; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; @@ -399,24 +398,13 @@ public class ApplicationApiHandler extends LoggingRequestHandler { ApplicationId application = ApplicationId.from(tenantName, applicationName, instanceName); ZoneId zone = ZoneId.from(environment, region); DeploymentId deployment = new DeploymentId(application, zone); - - if (queryParameters.containsKey("streaming")) { - InputStream logStream = controller.configServer().getLogStream(deployment, queryParameters); - return new HttpResponse(200) { - @Override - public void render(OutputStream outputStream) throws IOException { - logStream.transferTo(outputStream); - } - }; - } - - Optional response = controller.configServer().getLogs(deployment, queryParameters); - Slime slime = new Slime(); - Cursor object = slime.setObject(); - if (response.isPresent()) { - response.get().logs().entrySet().stream().forEach(entry -> object.setString(entry.getKey(), entry.getValue())); - } - return new SlimeJsonResponse(slime); + InputStream logStream = controller.configServer().getLogs(deployment, queryParameters); + return new HttpResponse(200) { + @Override + public void render(OutputStream outputStream) throws IOException { + logStream.transferTo(outputStream); + } + }; } private HttpResponse trigger(ApplicationId id, JobType type, HttpRequest request) { diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java index 962289274c7..e201258c701 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java @@ -17,7 +17,6 @@ import com.yahoo.vespa.hosted.controller.api.identifiers.TenantId; import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServer; import com.yahoo.vespa.hosted.controller.api.integration.configserver.LoadBalancer; import com.yahoo.vespa.hosted.controller.api.integration.configserver.Log; -import com.yahoo.vespa.hosted.controller.api.integration.configserver.Logs; import com.yahoo.vespa.hosted.controller.api.integration.configserver.Node; import com.yahoo.vespa.hosted.controller.api.integration.configserver.NotFoundException; import com.yahoo.vespa.hosted.controller.api.integration.configserver.PrepareResponse; @@ -366,15 +365,7 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer } @Override - public Optional getLogs(DeploymentId deployment, Map queryParameters) { - HashMap logs = new HashMap<>(); - logs.put("subfolder-log2.log", "VGhpcyBpcyBhbm90aGVyIGxvZyBmaWxl"); - logs.put("log1.log", "VGhpcyBpcyBvbmUgbG9nIGZpbGU="); - return Optional.of(new Logs(logs)); - } - - @Override - public InputStream getLogStream(DeploymentId deployment, Map queryParameters) { + public InputStream getLogs(DeploymentId deployment, Map queryParameters) { return IOUtils.toInputStream(log); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java index 3fcead5d0b6..1616ac87642 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java @@ -402,10 +402,7 @@ public class ApplicationApiTest extends ControllerContainerTest { new File("application-nodes.json")); // GET logs - tester.assertResponse(request("/application/v4/tenant/tenant2/application/application1/environment/prod/region/us-central-1/instance/default/logs?from=1233&to=3214", GET) - .userIdentity(USER_ID), - new File("logs.json")); - tester.assertResponse(request("/application/v4/tenant/tenant2/application/application1/environment/dev/region/us-central-1/instance/default/logs?from=1233&to=3214&streaming", GET) + tester.assertResponse(request("/application/v4/tenant/tenant2/application/application1/environment/dev/region/us-central-1/instance/default/logs?from=1233&to=3214", GET) .userIdentity(USER_ID), "INFO - All good"); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/logs.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/logs.json deleted file mode 100644 index 69fc0f88ea6..00000000000 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/logs.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "subfolder-log2.log":"VGhpcyBpcyBhbm90aGVyIGxvZyBmaWxl", - "log1.log":"VGhpcyBpcyBvbmUgbG9nIGZpbGU=" -} \ No newline at end of file -- cgit v1.2.3