aboutsummaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2018-05-22 12:21:28 +0200
committerMartin Polden <mpolden@mpolden.no>2018-05-22 12:21:28 +0200
commit5d4c84e00f512ed2f096c57edd761451310fc54a (patch)
tree32dd4b57b91eac9a73fd2c08b55c3662f4f0fa63 /configserver
parent00f4225c4f1943d6b7ba5d5fb4c699a2425b7f83 (diff)
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());