summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2022-08-18 11:28:58 +0200
committerjonmv <venstad@gmail.com>2022-08-18 11:28:58 +0200
commit9a4ffe4ccffe90d0ab97fcfbd848e2247e70f34e (patch)
tree0c61f32a85ff080082f7ca313c8dfaff8fdb9373 /controller-server
parent8cf01d7053ed981dbed0ad2f95ffbb917277b18c (diff)
Limit Vespa logs to copy to 10s before deployment completed at controller
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java44
1 files changed, 24 insertions, 20 deletions
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 7114402f824..11a784ce899 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
@@ -233,41 +233,45 @@ public class JobController {
Run run = run(id);
return run.stepStatus(copyVespaLogs).map(succeeded::equals).orElse(false)
? controller.serviceRegistry().runDataStore().getLogs(id, tester)
- : getVespaLogsFromLogserver(run, fromMillis, tester);
+ : getVespaLogsFromLogserver(run, fromMillis, tester).orElse(InputStream.nullInputStream());
}
public static Optional<Instant> deploymentCompletedAt(Run run, boolean tester) {
return (tester ? run.stepInfo(installTester)
: run.stepInfo(installInitialReal).or(() -> run.stepInfo(installReal)))
- .flatMap(StepInfo::startTime);
+ .flatMap(StepInfo::startTime).map(start -> start.minusSeconds(10));
}
public void storeVespaLogs(RunId id) {
Run run = run(id);
if ( ! id.type().isProduction()) {
- try (InputStream logs = getVespaLogsFromLogserver(run, 0, false)) {
- controller.serviceRegistry().runDataStore().putLogs(id, false, logs);
- }
- catch (IOException e) {
- throw new UncheckedIOException(e);
- }
+ getVespaLogsFromLogserver(run, 0, false).ifPresent(logs -> {
+ try (logs) {
+ controller.serviceRegistry().runDataStore().putLogs(id, false, logs);
+ }
+ catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ });
}
if (id.type().isTest()) {
- try (InputStream logs = getVespaLogsFromLogserver(run, 0, true)) {
- controller.serviceRegistry().runDataStore().putLogs(id, true, logs);
- }
- catch (IOException e) {
- throw new UncheckedIOException(e);
- }
+ getVespaLogsFromLogserver(run, 0, true).ifPresent(logs -> {
+ try (logs) {
+ controller.serviceRegistry().runDataStore().putLogs(id, true, logs);
+ }
+ catch(IOException e){
+ throw new UncheckedIOException(e);
+ }
+ });
}
}
- private InputStream getVespaLogsFromLogserver(Run run, long fromMillis, boolean tester) {
- long deploymentCompletedAtMillis = deploymentCompletedAt(run, tester).orElse(Instant.EPOCH).toEpochMilli();
- return controller.serviceRegistry().configServer().getLogs(new DeploymentId(tester ? run.id().tester().id() : run.id().application(),
- run.id().type().zone()),
- Map.of("from", Long.toString(Math.max(fromMillis, deploymentCompletedAtMillis)),
- "to", Long.toString(run.end().orElse(controller.clock().instant()).toEpochMilli())));
+ private Optional<InputStream> getVespaLogsFromLogserver(Run run, long fromMillis, boolean tester) {
+ return deploymentCompletedAt(run, tester).map(at ->
+ controller.serviceRegistry().configServer().getLogs(new DeploymentId(tester ? run.id().tester().id() : run.id().application(),
+ run.id().type().zone()),
+ Map.of("from", Long.toString(Math.max(fromMillis, at.toEpochMilli())),
+ "to", Long.toString(run.end().orElse(controller.clock().instant()).toEpochMilli()))));
}
/** Fetches any new test log entries, and records the id of the last of these, for continuation. */