summaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@users.noreply.github.com>2019-05-27 13:40:42 +0200
committerGitHub <noreply@github.com>2019-05-27 13:40:42 +0200
commitdb1b509e6c6c7ca0bb5ea9605e5934f697b77083 (patch)
tree630be98bfd2e5ad23984f2f675b4f8f513b64ad0 /node-repository
parent9a06532abab50090c7fa6b51681bba54967e3a69 (diff)
parentfe7c2d0dadd0313fbd48d5812b756437e84e8d84 (diff)
Merge pull request #9531 from vespa-engine/jvenstad/config-super-model-last-take
Jvenstad/config super model last take
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));
}