summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@oath.com>2018-07-06 11:22:03 +0200
committerHarald Musum <musum@oath.com>2018-07-06 11:22:03 +0200
commit908b76d684bff7b4bc77269ee2f2f53a0c8c2a46 (patch)
tree199d99a3a96a454bb8aedc240a3429bd622ff4bd /configserver
parenta9e1f8619ae5a4db3e0909ade11feaf4a263d8ce (diff)
Do not upgrade applications to current version when bootstrapping in manually deployed zones
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java42
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java17
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java14
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/deploy/MockDeployer.java12
4 files changed, 58 insertions, 27 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
index 94d758237de..e8cfcf75de3 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
@@ -202,7 +202,25 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
*/
@Override
public Optional<com.yahoo.config.provision.Deployment> deployFromLocalActive(ApplicationId application) {
- return deployFromLocalActive(application, Duration.ofSeconds(configserverConfig.zookeeper().barrierTimeout()).plus(Duration.ofSeconds(5)));
+ return deployFromLocalActive(application, false);
+ }
+
+ /**
+ * Creates a new deployment from the active application, if available.
+ * This is used for system internal redeployments, not on application package changes.
+ *
+ * @param application the active application to be redeployed
+ * @param bootstrap the deployment is done when bootstrapping
+ * @return a new deployment from the local active, or empty if a local active application
+ * was not present for this id (meaning it either is not active or active on another
+ * node in the config server cluster)
+ */
+ @Override
+ public Optional<com.yahoo.config.provision.Deployment> deployFromLocalActive(ApplicationId application,
+ boolean bootstrap) {
+ return deployFromLocalActive(application,
+ Duration.ofSeconds(configserverConfig.zookeeper().barrierTimeout()).plus(Duration.ofSeconds(5)),
+ bootstrap);
}
/**
@@ -211,13 +229,15 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
*
* @param application the active application to be redeployed
* @param timeout the timeout to use for each individual deployment operation
+ * @param bootstrap the deployment is done when bootstrapping
* @return a new deployment from the local active, or empty if a local active application
* was not present for this id (meaning it either is not active or active on another
* node in the config server cluster)
*/
@Override
public Optional<com.yahoo.config.provision.Deployment> deployFromLocalActive(ApplicationId application,
- Duration timeout) {
+ Duration timeout,
+ boolean bootstrap) {
Tenant tenant = tenantRepository.getTenant(application.tenant());
if (tenant == null) return Optional.empty();
LocalSession activeSession = getActiveSession(tenant, application);
@@ -228,10 +248,11 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
// Keep manually deployed tenant applications on the latest version, don't change version otherwise
// TODO: Remove this and always use version from session once controller starts upgrading manual deployments
- Version version = decideVersion(application, environment, newSession.getVespaVersion());
+ Version version = decideVersion(application, environment, newSession.getVespaVersion(), bootstrap);
return Optional.of(Deployment.unprepared(newSession, this, hostProvisioner, tenant, timeout, clock,
- false /* don't validate as this is already deployed */, version));
+ false /* don't validate as this is already deployed */, version,
+ bootstrap));
}
@Override
@@ -257,7 +278,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
}
private Deployment deployFromPreparedSession(LocalSession session, Tenant tenant, Duration timeout) {
- return Deployment.prepared(session, this, hostProvisioner, tenant, timeout, clock);
+ return Deployment.prepared(session, this, hostProvisioner, tenant, timeout, clock, false);
}
// ---------------- Application operations ----------------------------------------------------------------
@@ -672,12 +693,10 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
Set<ApplicationId> failedDeployments = new HashSet<>();
for (ApplicationId appId : applicationIds) {
- Optional<com.yahoo.config.provision.Deployment> deploymentOptional = deployFromLocalActive(appId);
+ Optional<com.yahoo.config.provision.Deployment> deploymentOptional = deployFromLocalActive(appId, true /* bootstrap */);
if ( ! deploymentOptional.isPresent()) continue;
- Deployment deployment = (Deployment)deploymentOptional.get();
- deployment.setBootstrap(true); // Only available inside the config server; hence the cast
- futures.put(appId, executor.submit(deployment::activate));
+ futures.put(appId, executor.submit(deploymentOptional.get()::activate));
}
for (Map.Entry<ApplicationId, Future<?>> f : futures.entrySet()) {
@@ -723,9 +742,10 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
}
/** Returns version to use when deploying application in given environment */
- static Version decideVersion(ApplicationId application, Environment environment, Version targetVersion) {
+ static Version decideVersion(ApplicationId application, Environment environment, Version targetVersion, boolean bootstrap) {
if (environment.isManuallyDeployed() &&
- !"hosted-vespa".equals(application.tenant().value())) { // Never change version of system applications
+ !"hosted-vespa".equals(application.tenant().value()) && // Never change version of system applications
+ !bootstrap) { // Do not use current version when bootstrapping config server
return Vtag.currentVersion;
}
return targetVersion;
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java
index acc5e8dcf61..06b413a97ce 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java
@@ -48,6 +48,9 @@ public class Deployment implements com.yahoo.config.provision.Deployment {
/** The Vespa version this application should run on */
private final Version version;
+ /** True if this deployment is done to bootstrap the config server */
+ private final boolean isBootstrap;
+
private boolean prepared = false;
/** Whether this model should be validated (only takes effect if prepared=false) */
@@ -56,8 +59,6 @@ public class Deployment implements com.yahoo.config.provision.Deployment {
private boolean ignoreLockFailure = false;
private boolean ignoreSessionStaleFailure = false;
- private boolean isBootstrap = false;
-
private Deployment(LocalSession session, ApplicationRepository applicationRepository,
Optional<Provisioner> hostProvisioner, Tenant tenant,
Duration timeout, Clock clock, boolean prepared, boolean validate, Version version,
@@ -76,16 +77,17 @@ public class Deployment implements com.yahoo.config.provision.Deployment {
public static Deployment unprepared(LocalSession session, ApplicationRepository applicationRepository,
Optional<Provisioner> hostProvisioner, Tenant tenant,
- Duration timeout, Clock clock, boolean validate, Version version) {
+ Duration timeout, Clock clock, boolean validate, Version version,
+ boolean isBootstrap) {
return new Deployment(session, applicationRepository, hostProvisioner, tenant,
- timeout, clock, false, validate, version, false);
+ timeout, clock, false, validate, version, isBootstrap);
}
public static Deployment prepared(LocalSession session, ApplicationRepository applicationRepository,
Optional<Provisioner> hostProvisioner, Tenant tenant,
- Duration timeout, Clock clock) {
+ Duration timeout, Clock clock, boolean isBootstrap) {
return new Deployment(session, applicationRepository, hostProvisioner, tenant,
- timeout, clock, true, true, session.getVespaVersion(), false);
+ timeout, clock, true, true, session.getVespaVersion(), isBootstrap);
}
public Deployment setIgnoreLockFailure(boolean ignoreLockFailure) {
@@ -171,9 +173,6 @@ public class Deployment implements com.yahoo.config.provision.Deployment {
hostProvisioner.get().restart(session.getApplicationId(), filter);
}
- /** Set this to true if this deployment is done to bootstrap the config server */
- public void setBootstrap(boolean isBootstrap) { this.isBootstrap = isBootstrap; }
-
/** Exposes the session of this for testing only */
public LocalSession session() { return session; }
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
index e2d59fb2108..18e2525f61a 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
@@ -130,14 +130,16 @@ public class ApplicationRepositoryTest {
Version targetVersion = Version.fromString("5.0");
// Always use target for system application
- assertEquals(targetVersion, ApplicationRepository.decideVersion(systemApp, Environment.prod, targetVersion));
- assertEquals(targetVersion, ApplicationRepository.decideVersion(systemApp, Environment.dev, targetVersion));
- assertEquals(targetVersion, ApplicationRepository.decideVersion(systemApp, Environment.perf, targetVersion));
+ assertEquals(targetVersion, ApplicationRepository.decideVersion(systemApp, Environment.prod, targetVersion, false));
+ assertEquals(targetVersion, ApplicationRepository.decideVersion(systemApp, Environment.dev, targetVersion, false));
+ assertEquals(targetVersion, ApplicationRepository.decideVersion(systemApp, Environment.perf, targetVersion, false));
// Target for regular application depends on environment
- assertEquals(targetVersion, ApplicationRepository.decideVersion(regularApp, Environment.prod, targetVersion));
- assertEquals(Vtag.currentVersion, ApplicationRepository.decideVersion(regularApp, Environment.dev, targetVersion));
- assertEquals(Vtag.currentVersion, ApplicationRepository.decideVersion(regularApp, Environment.perf, targetVersion));
+ assertEquals(targetVersion, ApplicationRepository.decideVersion(regularApp, Environment.prod, targetVersion, false));
+ assertEquals(Vtag.currentVersion, ApplicationRepository.decideVersion(regularApp, Environment.dev, targetVersion, false));
+ // If bootstrap, version should be target version
+ assertEquals(targetVersion, ApplicationRepository.decideVersion(regularApp, Environment.dev, targetVersion, true));
+ assertEquals(Vtag.currentVersion, ApplicationRepository.decideVersion(regularApp, Environment.perf, targetVersion, false));
}
@Test
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/MockDeployer.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/MockDeployer.java
index 69176130b4b..da387eb569a 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/MockDeployer.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/MockDeployer.java
@@ -9,7 +9,7 @@ import java.time.Instant;
import java.util.Optional;
/**
- * @author lulf
+ * @author Ulf Lilleengen
*/
public class MockDeployer implements com.yahoo.config.provision.Deployer {
@@ -21,12 +21,22 @@ public class MockDeployer implements com.yahoo.config.provision.Deployer {
}
@Override
+ public Optional<Deployment> deployFromLocalActive(ApplicationId application, boolean bootstrap) {
+ return Optional.empty();
+ }
+
+ @Override
public Optional<Deployment> deployFromLocalActive(ApplicationId application, Duration timeout) {
lastDeployed = application;
return Optional.empty();
}
@Override
+ public Optional<Deployment> deployFromLocalActive(ApplicationId application, Duration timeout, boolean bootstrap) {
+ return Optional.empty();
+ }
+
+ @Override
public Optional<Instant> lastDeployTime(ApplicationId application) {
return Optional.empty();
}