diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2021-08-18 12:56:28 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2021-08-18 12:56:28 +0200 |
commit | e20589711989c29aae24a649cef0ab2a41cb464b (patch) | |
tree | 518507a6d4acebc62219cf1075f152b30fe4d410 /configserver | |
parent | 5b61adcd248e9bd9f191c21c6d0a6dc39cf78d60 (diff) |
Reject non-bootstrap deployments with unknown wanted Vespa version
Diffstat (limited to 'configserver')
3 files changed, 35 insertions, 0 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java index 9e1243a52a4..c2fc64c615c 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java @@ -37,6 +37,7 @@ import com.yahoo.vespa.config.server.filedistribution.FileDistributionFactory; import com.yahoo.vespa.config.server.filedistribution.FileDistributionProvider; import com.yahoo.vespa.config.server.host.HostValidator; import com.yahoo.vespa.config.server.http.InvalidApplicationException; +import com.yahoo.vespa.config.server.http.UnknownVespaVersionException; import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry; import com.yahoo.vespa.config.server.modelfactory.PreparedModelsBuilder; import com.yahoo.vespa.config.server.provision.HostProvisionerProvider; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java index 3c8437cfe18..72e7391098d 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java @@ -31,6 +31,7 @@ import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.configchange.ConfigChangeActions; import com.yahoo.vespa.config.server.deploy.TenantFileSystemDirs; import com.yahoo.vespa.config.server.filedistribution.FileDirectory; +import com.yahoo.vespa.config.server.http.UnknownVespaVersionException; import com.yahoo.vespa.config.server.modelfactory.ActivatedModelsBuilder; import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry; import com.yahoo.vespa.config.server.monitoring.MetricUpdater; @@ -222,6 +223,11 @@ public class SessionRepository { } public ConfigChangeActions prepareLocalSession(Session session, DeployLogger logger, PrepareParams params, Instant now) { + params.vespaVersion().ifPresent(version -> { + if ( ! params.isBootstrap() && ! modelFactoryRegistry.allVersions().contains(version)) + throw new UnknownVespaVersionException("Vespa version '" + version + "' not known by this configserver"); + }); + applicationRepo.createApplication(params.getApplicationId()); // TODO jvenstad: This is wrong, but it has to be done now, since preparation can change the application ID of a session :( logger.log(Level.FINE, "Created application " + params.getApplicationId()); long sessionId = session.getSessionId(); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java index 01b2af7d219..5b477c164c9 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java @@ -23,7 +23,9 @@ import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.Zone; import com.yahoo.test.ManualClock; import com.yahoo.vespa.config.server.application.ApplicationReindexing; +import com.yahoo.vespa.config.server.http.InternalServerException; import com.yahoo.vespa.config.server.http.InvalidApplicationException; +import com.yahoo.vespa.config.server.http.UnknownVespaVersionException; import com.yahoo.vespa.config.server.http.v2.PrepareResult; import com.yahoo.vespa.config.server.model.TestModelFactory; import com.yahoo.vespa.config.server.session.PrepareParams; @@ -118,6 +120,7 @@ public class HostedDeployTest { .modelFactory(createHostedModelFactory(Version.fromString("4.5.6"), Clock.systemUTC())) .configserverConfig(createConfigserverConfig()).build(); tester.deployApp("src/test/apps/hosted/", new PrepareParams.Builder() + .vespaVersion("4.5.6") .tenantSecretStores(tenantSecretStores)); Optional<com.yahoo.config.provision.Deployment> deployment = tester.redeployFromLocalActive(tester.applicationId()); @@ -127,6 +130,31 @@ public class HostedDeployTest { } @Test + public void testDeployOnUnknownVersion() throws IOException { + List<ModelFactory> modelFactories = List.of(createHostedModelFactory(Version.fromString("1.0.0"))); + DeployTester tester = new DeployTester.Builder().modelFactories(modelFactories).configserverConfig(createConfigserverConfig()).build(); + + // No version requested: OK + tester.deployApp("src/test/apps/hosted/", new PrepareParams.Builder()); + + // Bootstrap deployment on wrong version: OK (Must be allowed for self-hosted upgrades.) + try { + tester.deployApp("src/test/apps/hosted/", new PrepareParams.Builder().vespaVersion("1.0.1").isBootstrap(true)); + } + catch (InternalServerException expected) { // Fails actual building, since this is hosted, but self-hosted this is OK. + assertTrue(expected.getCause() instanceof UnknownVespaVersionException); + } + + + // Regular deployment with requested, unknown version: not OK. + try { + tester.deployApp("src/test/apps/hosted/", new PrepareParams.Builder().vespaVersion("1.0.1")); + fail("Requesting an unknown node version should not be allowed"); + } + catch (UnknownVespaVersionException expected) { } + } + + @Test public void testDeployMultipleVersions() throws IOException { List<ModelFactory> modelFactories = List.of(createHostedModelFactory(Version.fromString("6.1.0")), createHostedModelFactory(Version.fromString("6.2.0")), |