diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-05-30 16:37:09 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-05-30 16:37:09 +0200 |
commit | d12d6ec23605ce29cc9d1848d154ee64cf19ce8a (patch) | |
tree | 166bece42fdcec24616426fddcb191583d6cae59 /configserver | |
parent | af948fdb7a3e6e917f7653e127e63650adcef0a5 (diff) |
Auto-upgrade manually deployed applications
Diffstat (limited to 'configserver')
11 files changed, 52 insertions, 18 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 17e6db08068..3e132137468 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 @@ -2,10 +2,14 @@ package com.yahoo.vespa.config.server; import com.google.inject.Inject; +import com.yahoo.cloud.config.ConfigserverConfig; +import com.yahoo.component.Version; +import com.yahoo.component.Vtag; import com.yahoo.config.application.api.ApplicationFile; import com.yahoo.config.application.api.ApplicationMetaData; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.HostFilter; import com.yahoo.config.provision.Provisioner; import com.yahoo.config.provision.TenantName; @@ -62,6 +66,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye private final HttpProxy httpProxy; private final Clock clock; private final DeployLogger logger = new SilentDeployLogger(); + private final Environment environment; @Inject public ApplicationRepository(Tenants tenants, @@ -69,7 +74,8 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye Curator curator, LogServerLogGrabber logServerLogGrabber, ApplicationConvergenceChecker applicationConvergenceChecker, - HttpProxy httpProxy) { + HttpProxy httpProxy, + ConfigserverConfig configserverConfig) { this.tenants = tenants; this.hostProvisioner = hostProvisionerProvider.getHostProvisioner(); this.curator = curator; @@ -77,6 +83,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye this.convergeChecker = applicationConvergenceChecker; this.httpProxy = httpProxy; this.clock = Clock.systemUTC(); + this.environment = Environment.from(configserverConfig.environment()); } /** @@ -96,6 +103,10 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye TimeoutBudget timeoutBudget = new TimeoutBudget(clock, timeout); 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(); + return Optional.of(Deployment.unprepared(newSession, tenant.getLocalSessionRepo(), tenant.getPath(), @@ -103,7 +114,8 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye new ActivateLock(curator, tenant.getPath()), timeout, clock, - /* already deployed, validate: */ false)); + false, // don't validate as this is already deployed + version)); } public Deployment deployFromPreparedSession(LocalSession session, ActivateLock lock, LocalSessionRepo localSessionRepo, Duration timeout) { @@ -111,7 +123,8 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye localSessionRepo, hostProvisioner, lock, - timeout, clock); + timeout, + clock); } /** diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/HttpProxy.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/HttpProxy.java index e378777192f..526aaf4c9c6 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/HttpProxy.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/HttpProxy.java @@ -19,6 +19,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; public class HttpProxy { + private static Logger logger = Logger.getLogger(HttpProxy.class.getName()); private final HttpFetcher fetcher; @@ -64,4 +65,5 @@ public class HttpProxy { HttpFetcher.Params params = new HttpFetcher.Params(2000); // 2_000 ms read timeout return fetcher.get(params, url); } + } 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 81e52e0e129..891d6614583 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 @@ -1,7 +1,10 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.deploy; +import com.yahoo.component.Version; +import com.yahoo.component.Vtag; import com.yahoo.config.application.api.DeployLogger; +import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.HostFilter; import com.yahoo.config.provision.Provisioner; import com.yahoo.log.LogLevel; @@ -45,6 +48,9 @@ public class Deployment implements com.yahoo.config.provision.Deployment { private final Duration timeout; private final Clock clock; private final DeployLogger logger = new SilentDeployLogger(); + + /** The Vespa version this application should run on */ + private final Version version; private boolean prepared = false; @@ -56,7 +62,7 @@ public class Deployment implements com.yahoo.config.provision.Deployment { private Deployment(LocalSession session, LocalSessionRepo localSessionRepo, Path tenantPath, Optional<Provisioner> hostProvisioner, ActivateLock activateLock, - Duration timeout, Clock clock, boolean prepared, boolean validate) { + Duration timeout, Clock clock, boolean prepared, boolean validate, Version version) { this.session = session; this.localSessionRepo = localSessionRepo; this.tenantPath = tenantPath; @@ -66,20 +72,21 @@ public class Deployment implements com.yahoo.config.provision.Deployment { this.clock = clock; this.prepared = prepared; this.validate = validate; + this.version = version; } public static Deployment unprepared(LocalSession session, LocalSessionRepo localSessionRepo, Path tenantPath, Optional<Provisioner> hostProvisioner, ActivateLock activateLock, - Duration timeout, Clock clock, boolean validate) { + Duration timeout, Clock clock, boolean validate, Version version) { return new Deployment(session, localSessionRepo, tenantPath, hostProvisioner, activateLock, - timeout, clock, false, validate); + timeout, clock, false, validate, version); } public static Deployment prepared(LocalSession session, LocalSessionRepo localSessionRepo, Optional<Provisioner> hostProvisioner, ActivateLock activateLock, Duration timeout, Clock clock) { return new Deployment(session, localSessionRepo, null, hostProvisioner, activateLock, - timeout, clock, true, true); + timeout, clock, true, true, session.getVespaVersion()); } public Deployment setIgnoreLockFailure(boolean ignoreLockFailure) { @@ -97,12 +104,12 @@ public class Deployment implements com.yahoo.config.provision.Deployment { public void prepare() { if (prepared) return; TimeoutBudget timeoutBudget = new TimeoutBudget(clock, timeout); + session.prepare(logger, - /** Assumes that session has already set application id and version, see {@link com.yahoo.vespa.config.server.session.SessionFactoryImpl}. */ new PrepareParams.Builder().applicationId(session.getApplicationId()) .timeoutBudget(timeoutBudget) .ignoreValidationErrors( ! validate) - .vespaVersion(session.getVespaVersion().toString()) + .vespaVersion(version.toString()) .build(), Optional.empty(), tenantPath); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java index 70c855f064c..b37a54c6db0 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java @@ -78,7 +78,7 @@ public class ActivatedModelsBuilder extends ModelsBuilder<Application> { ServerCache cache = zkClient.loadServerCache(); ModelContext modelContext = new ModelContextImpl( applicationPackage, - Optional.<Model>empty(), + Optional.empty(), permanentApplicationPackage.get().applicationPackage(), logger, configDefinitionRepo, diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java index a1b8b4192c8..7c2b36d4d72 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java @@ -152,7 +152,8 @@ public class DeployTester { curator, new LogServerLogGrabber(), new ApplicationConvergenceChecker(), - new HttpProxy(new SimpleHttpFetcher())); + new HttpProxy(new SimpleHttpFetcher()), + new ConfigserverConfig(new ConfigserverConfig.Builder())); return applicationRepository.deployFromLocalActive(id, Duration.ofSeconds(60)); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java index 6eb730d11dc..199d592deb5 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java @@ -1,6 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.http.v2; +import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.config.model.application.provider.FilesApplicationPackage; import com.yahoo.config.provision.TenantName; import com.yahoo.config.provision.Zone; @@ -65,7 +66,8 @@ public class ApplicationContentHandlerTest extends ContentHandlerTestBase { new MockCurator(), new LogServerLogGrabber(), new ApplicationConvergenceChecker(), - new HttpProxy(new SimpleHttpFetcher()))); + new HttpProxy(new SimpleHttpFetcher()), + new ConfigserverConfig(new ConfigserverConfig.Builder()))); pathPrefix = createPath(idTenant1, Zone.defaultZone()); baseUrl = baseServer + pathPrefix; } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java index c34cb565878..330c13892ad 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java @@ -2,6 +2,7 @@ package com.yahoo.vespa.config.server.http.v2; import com.fasterxml.jackson.databind.ObjectMapper; +import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.model.NullConfigModelRegistry; import com.yahoo.config.model.application.provider.FilesApplicationPackage; @@ -114,7 +115,8 @@ public class ApplicationHandlerTest { new MockCurator(), logServerLogGrabber, convergeChecker, - httpProxy)); + httpProxy, + new ConfigserverConfig(new ConfigserverConfig.Builder()))); } private ApplicationHandler createApplicationHandler(Tenants tenants) { @@ -127,7 +129,8 @@ public class ApplicationHandlerTest { new MockCurator(), new LogServerLogGrabber(), new ApplicationConvergenceChecker(stateApiFactory), - new HttpProxy(new SimpleHttpFetcher()))); + new HttpProxy(new SimpleHttpFetcher()), + new ConfigserverConfig(new ConfigserverConfig.Builder()))); } @Test diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java index 2d76e9aa2cc..f5bac7b0abc 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java @@ -1,6 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.http.v2; +import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ApplicationName; import com.yahoo.config.provision.Capacity; @@ -183,7 +184,8 @@ public class SessionActiveHandlerTest extends SessionActiveHandlerTestBase { curator, new LogServerLogGrabber(), new ApplicationConvergenceChecker(), - new HttpProxy(new SimpleHttpFetcher()))); + new HttpProxy(new SimpleHttpFetcher()), + new ConfigserverConfig(new ConfigserverConfig.Builder()))); } public static class MockProvisioner implements Provisioner { diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java index 7f5ab96d76a..caef49e922f 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java @@ -2,6 +2,7 @@ package com.yahoo.vespa.config.server.http.v2; import com.google.common.io.Files; +import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.config.model.application.provider.FilesApplicationPackage; import com.yahoo.config.provision.TenantName; import com.yahoo.container.jdisc.HttpResponse; @@ -178,6 +179,7 @@ public class SessionContentHandlerTest extends ContentHandlerTestBase { new MockCurator(), new LogServerLogGrabber(), new ApplicationConvergenceChecker(), - new HttpProxy(new SimpleHttpFetcher()))); + new HttpProxy(new SimpleHttpFetcher()), + new ConfigserverConfig(new ConfigserverConfig.Builder()))); } } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java index 107297743e1..04d8f35b2d4 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java @@ -252,7 +252,8 @@ public class SessionCreateHandlerTest extends SessionHandlerTest { new MockCurator(), new LogServerLogGrabber(), new ApplicationConvergenceChecker(), - new HttpProxy(new SimpleHttpFetcher()))); + new HttpProxy(new SimpleHttpFetcher()), + new ConfigserverConfig(new ConfigserverConfig.Builder()))); } public HttpRequest post() throws FileNotFoundException { diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java index f10a7ffd502..6ca7a2922b6 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java @@ -373,7 +373,8 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest { new MockCurator(), new LogServerLogGrabber(), new ApplicationConvergenceChecker(), - new HttpProxy(new SimpleHttpFetcher()))); + new HttpProxy(new SimpleHttpFetcher()), + new ConfigserverConfig(new ConfigserverConfig.Builder()))); } private TestTenantBuilder addTenant(TenantName tenantName, |