summaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorJon Marius Venstad <jvenstad@yahoo-inc.com>2019-05-24 09:05:58 +0200
committerJon Marius Venstad <jvenstad@yahoo-inc.com>2019-05-24 09:05:58 +0200
commita27c4f1864f1417bef1377e467134a537afda35d (patch)
tree876cac60b83f957db5d1359a3140c50390c8210d /node-repository
parent4f3abd21cb6fbbc0c50abc88902d56e623a68a25 (diff)
Revert "Revert "Revert 9366 revert 9351 jvenstad/last config model fix commits""
This reverts commit 58117f225da702d3a9481255e7abd945bc83fb68.
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));
}