summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@oath.com>2018-05-22 13:10:35 +0200
committerGitHub <noreply@github.com>2018-05-22 13:10:35 +0200
commitca27b5e3ce621596e2c5780d6c17005382467e6d (patch)
tree4a2503d1e515dac93185e79114f47d64ce3b254b /configserver
parent5844b705da5ea0f953bf2950b13633c3b439eac9 (diff)
parent5d4c84e00f512ed2f096c57edd761451310fc54a (diff)
Merge pull request #5897 from vespa-engine/mpolden/avoid-incidental-upgrade-of-infrastructure
Stop upgrading hosted-vespa applications in manually deployed environments
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java16
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java20
2 files changed, 33 insertions, 3 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 d0da4870f4f..549af4d1f64 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
@@ -199,10 +199,11 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
LocalSession newSession = tenant.getSessionFactory().createSessionFromExisting(activeSession, logger, timeoutBudget);
tenant.getLocalSessionRepo().addSession(newSession);
- // Keep manually deployed applications on the latest version, don't change version otherwise
- Version version = environment.isManuallyDeployed() ? Vtag.currentVersion : newSession.getVespaVersion();
+ // 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());
- return Optional.of(Deployment.unprepared(newSession, this, hostProvisioner,tenant, timeout, clock,
+ return Optional.of(Deployment.unprepared(newSession, this, hostProvisioner, tenant, timeout, clock,
false /* don't validate as this is already deployed */, version));
}
@@ -518,6 +519,15 @@ 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) {
+ if (environment.isManuallyDeployed() &&
+ !"hosted-vespa".equals(application.tenant().value())) { // Never change version of system applications
+ return Vtag.currentVersion;
+ }
+ return targetVersion;
+ }
+
public Slime createDeployLog() {
Slime deployLog = new Slime();
deployLog.setObject();
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 17cbe41fde5..058e39eea9b 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
@@ -1,9 +1,12 @@
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server;
+import com.yahoo.component.Version;
+import com.yahoo.component.Vtag;
import com.yahoo.config.model.application.provider.FilesApplicationPackage;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.ApplicationName;
+import com.yahoo.config.provision.Environment;
import com.yahoo.config.provision.InstanceName;
import com.yahoo.config.provision.Provisioner;
import com.yahoo.config.provision.TenantName;
@@ -90,6 +93,23 @@ public class ApplicationRepositoryTest {
assertEquals(tenantName, applicationRepository.removeUnusedTenants().iterator().next());
}
+ @Test
+ public void decideVersion() {
+ ApplicationId regularApp = ApplicationId.from("tenant1", "application1", "default");
+ ApplicationId systemApp = ApplicationId.from("hosted-vespa", "routing", "default");
+ 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));
+
+ // 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));
+ }
+
private PrepareResult prepareAndActivateApp(File application) throws IOException {
FilesApplicationPackage appDir = FilesApplicationPackage.fromFile(application);
long sessionId = applicationRepository.createSession(applicationId(), timeoutBudget, appDir.getAppDir());