summaryrefslogtreecommitdiffstats
path: root/controller-server/src/main/java/com
diff options
context:
space:
mode:
authorJon Marius Venstad <jvenstad@yahoo-inc.com>2018-10-05 11:46:14 +0200
committerJon Marius Venstad <jvenstad@yahoo-inc.com>2018-10-05 11:46:14 +0200
commitc2422f665df5d177616998da0e492ff59042a680 (patch)
tree85031409c20e1c8b90c5e30287dbe1df5740aac2 /controller-server/src/main/java/com
parentf1eab23a3253838258249d8d422f11363927bdda (diff)
Relax reaction to trying to modify inactive run, and simplify
Diffstat (limited to 'controller-server/src/main/java/com')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java25
1 files changed, 10 insertions, 15 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 1c1c436bda7..d257672bf5b 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
@@ -114,23 +114,21 @@ public class JobController {
/** Fetches any new test log entries, and records the id of the last of these, for continuation. */
public void updateTestLog(RunId id) {
- try (Lock __ = curator.lock(id.application(), id.type())) {
- active(id).ifPresent(run -> {
+ locked(id, run -> {
if ( ! run.readySteps().contains(endTests))
- return;
+ return run;
Optional<URI> testerEndpoint = testerEndpoint(id);
if ( ! testerEndpoint.isPresent())
- return;
+ return run;
List<LogEntry> entries = cloud.getLog(testerEndpoint.get(), run.lastTestLogEntry());
if (entries.isEmpty())
- return;
+ return run;
logs.append(id.application(), id.type(), endTests, entries);
- curator.writeLastRun(run.with(entries.stream().mapToLong(LogEntry::id).max().getAsLong()));
+ return run.with(entries.stream().mapToLong(LogEntry::id).max().getAsLong());
});
- }
}
/** Returns a list of all application which have registered. */
@@ -268,11 +266,7 @@ public class JobController {
public void unregister(ApplicationId id) {
controller.applications().lockIfPresent(id, application -> {
controller.applications().store(application.withBuiltInternally(false));
- jobs(id).forEach(type -> {
- try (Lock __ = curator.lock(id, type)) {
- last(id, type).ifPresent(last -> active(last.id()).ifPresent(active -> abort(active.id())));
- }
- });
+ jobs(id).forEach(type -> last(id, type).ifPresent(last -> abort(last.id())));
});
}
@@ -359,9 +353,10 @@ public class JobController {
/** Locks and modifies the run with the given id, provided it is still active. */
private void locked(RunId id, UnaryOperator<Run> modifications) {
try (Lock __ = curator.lock(id.application(), id.type())) {
- Run run = active(id).orElseThrow(() -> new IllegalArgumentException(id + " is not an active run!"));
- run = modifications.apply(run);
- curator.writeLastRun(run);
+ active(id).ifPresent(run -> {
+ run = modifications.apply(run);
+ curator.writeLastRun(run);
+ });
}
}