diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-08-24 09:18:48 +0200 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-08-24 09:18:48 +0200 |
commit | 48cf0d0a45a14c38607267acbd47a7dd94e82c34 (patch) | |
tree | 751033ca38c52b62fb12509164ba8d32daacb634 | |
parent | 21e95c8db5ae40ab1e93070b3490629f57450f7c (diff) |
Use controller clock when job controller logs, and include traces
3 files changed, 14 insertions, 7 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogEntry.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogEntry.java index 7424b0409c9..026e9250cef 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogEntry.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogEntry.java @@ -26,10 +26,6 @@ public class LogEntry { this.message = requireNonNull(message); } - public static LogEntry of(LogRecord record) { - return new LogEntry(record.getSequenceNumber(), record.getMillis(), record.getLevel(), record.getMessage()); - } - public long id() { return id; } 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 40696909eec..91cffabeb12 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 @@ -27,7 +27,9 @@ import com.yahoo.vespa.hosted.controller.application.ApplicationVersion; import com.yahoo.vespa.hosted.controller.application.DeploymentJobs; import com.yahoo.yolean.Exceptions; +import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.PrintStream; import java.io.UncheckedIOException; import java.net.URI; import java.time.Duration; @@ -536,7 +538,14 @@ public class InternalStepRunner implements StepRunner { LogRecord record = new LogRecord(level, message); record.setThrown(thrown); logger.log(record); - controller.jobController().log(id, step, record); + + if (thrown != null) { + ByteArrayOutputStream traceBuffer = new ByteArrayOutputStream(); + thrown.printStackTrace(new PrintStream(traceBuffer)); + message += "\n" + traceBuffer; + } + + controller.jobController().log(id, step, level, message); } } 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 4759c03e9bb..ed844b96eda 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 @@ -30,6 +30,7 @@ import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import java.util.function.UnaryOperator; +import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.stream.Stream; @@ -93,9 +94,10 @@ public class JobController { } /** Stores the given log record for the given run and step. */ - public void log(RunId id, Step step, LogRecord record) { + public void log(RunId id, Step step, Level level, String message) { locked(id, __ -> { - logs.append(id.application(), id.type(), step, Collections.singletonList(LogEntry.of(record))); + LogEntry entry = new LogEntry(0, controller.clock().millis(), level, message); + logs.append(id.application(), id.type(), step, Collections.singletonList(entry)); return __; }); } |