summaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@users.noreply.github.com>2019-05-29 08:04:00 +0200
committerGitHub <noreply@github.com>2019-05-29 08:04:00 +0200
commitd4ea0c2444d246ddc5ca902aed615200477eea30 (patch)
treecc923dabca1a191600c76f967e7250e0d32c3a07 /node-repository
parent2c65d503bc8c64275c877df21df366a5f40d3788 (diff)
Revert "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, 17 insertions, 10 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 fde19f72191..96c8fe21959 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,6 +51,11 @@ 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.
*
@@ -70,18 +75,19 @@ public abstract class ApplicationMaintainer extends Maintainer {
/** Returns the applications that should be maintained by this now. */
protected abstract Set<ApplicationId> applicationsNeedingMaintenance();
- /** Redeploy this application. */
+ /** Redeploy this application. A lock will be taken for the duration of the deployment activation */
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.
- 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();
- });
+ //
+ // 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();
} 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 5474c8ab51d..174591b0836 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,7 +38,8 @@ public class PeriodicApplicationMaintainer extends ApplicationMaintainer {
this.start = clock.instant();
}
- private boolean canDeployNow(ApplicationId application) {
+ @Override
+ protected boolean canDeployNow(ApplicationId application) {
// Don't deploy if a regular deploy just happened
return getLastDeployTime(application).isBefore(nodeRepository().clock().instant().minus(minTimeBetweenRedeployments));
}