summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogStore.java24
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockLogStore.java41
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java43
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunDetails.java27
4 files changed, 53 insertions, 82 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogStore.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogStore.java
index 918047edca1..ef2d9077892 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogStore.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogStore.java
@@ -3,30 +3,20 @@ package com.yahoo.vespa.hosted.controller.api.integration;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.PrepareResponse;
import com.yahoo.vespa.hosted.controller.api.integration.deployment.RunId;
+import java.util.Optional;
+
/**
* @author freva
*/
public interface LogStore {
- /** @return the test log of the given deployment job. */
- String getTestLog(RunId id);
-
- /** Stores the given test log for the given deployment job. */
- void setTestLog(RunId id, String testLog);
-
- /** @return the convergence log of the given deployment job. */
- String getConvergenceLog(RunId id);
-
- /** Stores the given convergence log for the given deployment job. */
- void setConvergenceLog(RunId id, String convergenceLog);
-
- /** @return the result of prepare of the test application for the given deployment job. */
- String getDeploymentLog(RunId id);
+ /** @return the log of the given step of the given deployment job, or an empty byte array if non-existent. */
+ byte[] getLog(RunId id, String step);
- /** Stores the given result of prepare of the test application for the given deployment job. */
- void setDeploymentLog(RunId id, String deploymentLog);
+ /** Stores the given log for the given step of the given deployment job. */
+ void setLog(RunId id, String step, byte[] log);
- /** Deletes all data associated with test of a given deployment job */
+ /** Deletes all data associated with the given deployment job */
void deleteTestData(RunId id);
}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockLogStore.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockLogStore.java
index bc9f6247055..61e6ac1004b 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockLogStore.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockLogStore.java
@@ -1,52 +1,35 @@
// 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.stubs;
-import com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.ConfigChangeActions;
-import com.yahoo.vespa.hosted.controller.api.identifiers.TenantId;
import com.yahoo.vespa.hosted.controller.api.integration.LogStore;
-import com.yahoo.vespa.hosted.controller.api.integration.configserver.PrepareResponse;
import com.yahoo.vespa.hosted.controller.api.integration.deployment.RunId;
-import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
/**
- * @author freva
+ * @author jonmv
*/
public class MockLogStore implements LogStore {
- @Override
- public String getTestLog(RunId id) {
- return "SUCCESS";
- }
-
- @Override
- public void setTestLog(RunId id, String testLog) {
-
- }
+ private final Map<RunId, Map<String, byte[]>> storage = new ConcurrentHashMap<>();
@Override
- public String getConvergenceLog(RunId id) {
- return "SUCCESS";
+ public byte[] getLog(RunId id, String step) {
+ return storage.containsKey(id) && storage.get(id).containsKey(step)
+ ? storage.get(id).get(step)
+ : new byte[0];
}
@Override
- public void setConvergenceLog(RunId id, String convergenceLog) {
-
- }
-
- @Override
- public String getDeploymentLog(RunId id) {
- return "SUCCESS";
- }
-
- @Override
- public void setDeploymentLog(RunId id, String deploymentLog) {
-
+ public void setLog(RunId id, String step, byte[] log) {
+ storage.putIfAbsent(id, new ConcurrentHashMap<>());
+ storage.get(id).put(step, log);
}
@Override
public void deleteTestData(RunId id) {
-
+ storage.remove(id);
}
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java
index 9366a678e88..056dcba2cd5 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java
@@ -16,6 +16,8 @@ import com.yahoo.vespa.hosted.controller.application.JobStatus;
import com.yahoo.vespa.hosted.controller.application.SourceRevision;
import com.yahoo.vespa.hosted.controller.persistence.CuratorDb;
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -67,29 +69,32 @@ public class JobController {
}
}
- /** Returns the details currently logged for the given run. */
- public RunDetails details(RunId id) {
- return new RunDetails(logs.getDeploymentLog(id), logs.getConvergenceLog(id), logs.getTestLog(id));
- }
-
- /** Appends the given string to the currently stored deployment logs for the given run. */
- public void logDeployment(RunId id, String appendage) {
- try (Lock __ = curator.lock(id.application(), id.type())) {
- logs.setDeploymentLog(id, logs.getDeploymentLog(id).concat(appendage));
- }
- }
-
- /** Appends the given string to the currently stored convergence logs for the given run. */
- public void logConvergence(RunId id, String appendage) {
- try (Lock __ = curator.lock(id.application(), id.type())) {
- logs.setConvergenceLog(id, logs.getConvergenceLog(id).concat(appendage));
+ /** Returns the details currently logged for the given run, if known. */
+ public Optional<RunDetails> details(RunId id) {
+ RunStatus run = runs(id.application(), id.type()).get(id);
+ if (run == null)
+ return Optional.empty();
+
+ Map<Step, byte[]> details = new HashMap<>();
+ for (Step step : run.steps().keySet()) {
+ byte[] log = logs.getLog(id, step.name());
+ if (log.length > 0)
+ details.put(step, log);
}
+ return Optional.of(new RunDetails(details));
}
- /** Appends the given string to the currently stored test logs for the given run. */
- public void logTest(RunId id, String appendage) {
+ /** Appends the given log bytes to the currently stored bytes for the given run and step. */
+ public void log(RunId id, Step step, byte[] log) {
try (Lock __ = curator.lock(id.application(), id.type())) {
- logs.setTestLog(id, logs.getTestLog(id).concat(appendage));
+ byte[] stored = logs.getLog(id, step.name());
+ if (stored.length > 0) {
+ byte[] addition = log;
+ log = new byte[stored.length + addition.length];
+ System.arraycopy(stored, 0, log, 0, stored.length);
+ System.arraycopy(addition, 0, log, stored.length, addition.length);
+ }
+ logs.setLog(id, step.name(), log);
}
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunDetails.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunDetails.java
index 98969bd4508..ebe2b920d0a 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunDetails.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunDetails.java
@@ -1,5 +1,10 @@
package com.yahoo.vespa.hosted.controller.deployment;
+import com.google.common.collect.ImmutableMap;
+
+import java.util.Map;
+import java.util.Optional;
+
/**
* Contains details about a deployment job run.
*
@@ -7,26 +12,14 @@ package com.yahoo.vespa.hosted.controller.deployment;
*/
public class RunDetails {
- private final String deploymentLog;
- private final String convergenceLog;
- private final String testLog;
-
- public RunDetails(String deploymentLog, String convergenceLog, String testLog) {
- this.deploymentLog = deploymentLog;
- this.convergenceLog = convergenceLog;
- this.testLog = testLog;
- }
-
- public String getDeploymentLog() {
- return deploymentLog;
- }
+ private final Map<Step, byte[]> logs;
- public String getConvergenceLog() {
- return convergenceLog;
+ public RunDetails(Map<Step, byte[]> logs) {
+ this.logs = ImmutableMap.copyOf(logs);
}
- public String getTestLog() {
- return testLog;
+ public Optional<byte[]> get(Step step) {
+ return Optional.ofNullable(logs.get(step));
}
}