summaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@users.noreply.github.com>2019-05-10 20:16:30 +0200
committerGitHub <noreply@github.com>2019-05-10 20:16:30 +0200
commit24c10adbb940935ef70b7eedb33f485e3f3c4dbd (patch)
tree85b92cc714e4c7645ccc238fa7f123eab13bbba9 /node-repository
parenta3c78eea933d586d1c25394e1fb8302ecb7eca1a (diff)
parentb02b1bbad770dc4cdc05d5f01f24a127318e66f1 (diff)
Merge pull request #9351 from vespa-engine/jvenstad/last-config-model-fix-commits
Jvenstad/last config model fix commits
Diffstat (limited to 'node-repository')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/ApplicationMaintainer.java24
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/PeriodicApplicationMaintainer.java3
2 files changed, 10 insertions, 17 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/ApplicationMaintainer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/ApplicationMaintainer.java
index 96c8fe21959..fde19f72191 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/ApplicationMaintainer.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/ApplicationMaintainer.java
@@ -51,11 +51,6 @@ public abstract class ApplicationMaintainer extends Maintainer {
return pendingDeployments.size();
}
- /** Returns whether given application should be deployed at this moment in time */
- protected boolean canDeployNow(ApplicationId application) {
- return true;
- }
-
/**
* Redeploy this application.
*
@@ -75,19 +70,18 @@ public abstract class ApplicationMaintainer extends Maintainer {
/** Returns the applications that should be maintained by this now. */
protected abstract Set<ApplicationId> applicationsNeedingMaintenance();
- /** Redeploy this application. A lock will be taken for the duration of the deployment activation */
+ /** Redeploy this application. */
protected final void deployWithLock(ApplicationId application) {
// An application might change its state between the time the set of applications is retrieved and the
// time deployment happens. Lock the application and check if it's still active.
- //
- // Lock is acquired with a low timeout to reduce the chance of colliding with an external deployment.
- try (Mutex lock = nodeRepository().lock(application, Duration.ofSeconds(1))) {
- if ( ! isActive(application)) return; // became inactive since deployment was requested
- if ( ! canDeployNow(application)) return; // redeployment is no longer needed
- Optional<Deployment> deployment = deployer.deployFromLocalActive(application);
- if ( ! deployment.isPresent()) return; // this will be done at another config server
- log.log(LogLevel.DEBUG, this.getClass().getSimpleName() + " deploying " + application);
- deployment.get().activate();
+ try {
+ try (Mutex lock = nodeRepository().lock(application, Duration.ofSeconds(10))) {
+ if ( ! isActive(application)) return; // became inactive since deployment was requested
+ }
+ deployer.deployFromLocalActive(application).ifPresent(deployment -> { // if deployed on this config server
+ log.log(LogLevel.DEBUG, this.getClass().getSimpleName() + " deploying " + application);
+ deployment.activate();
+ });
} catch (RuntimeException e) {
log.log(LogLevel.WARNING, "Exception on maintenance redeploy", e);
} finally {
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/PeriodicApplicationMaintainer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/PeriodicApplicationMaintainer.java
index 174591b0836..5474c8ab51d 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/PeriodicApplicationMaintainer.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/PeriodicApplicationMaintainer.java
@@ -38,8 +38,7 @@ public class PeriodicApplicationMaintainer extends ApplicationMaintainer {
this.start = clock.instant();
}
- @Override
- protected boolean canDeployNow(ApplicationId application) {
+ private boolean canDeployNow(ApplicationId application) {
// Don't deploy if a regular deploy just happened
return getLastDeployTime(application).isBefore(nodeRepository().clock().instant().minus(minTimeBetweenRedeployments));
}