diff options
author | Martin Polden <mpolden@mpolden.no> | 2022-05-30 15:52:35 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2022-05-30 15:57:43 +0200 |
commit | cfc49c3b93988100bb0bc49776f70ce8d9fdd9b9 (patch) | |
tree | dc3aea3421b62538fcc107c1923ab706f91d9173 /controller-server | |
parent | 66392862e61c2f7d9d6d709429be5ab1bc2d7d0e (diff) |
Reject deployment spec using elements deprecated on previous major
Diffstat (limited to 'controller-server')
3 files changed, 30 insertions, 1 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackageValidator.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackageValidator.java index ccad4fe92ad..b097814eadd 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackageValidator.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackageValidator.java @@ -59,6 +59,16 @@ public class ApplicationPackageValidator { validateEndpointChange(application, applicationPackage, instant); validateCompactedEndpoint(applicationPackage); validateSecurityClientsPem(applicationPackage); + validateDeprecatedElements(applicationPackage); + } + + /** Verify that deployment spec does not use elements deprecated on a major version older than compile version */ + private void validateDeprecatedElements(ApplicationPackage applicationPackage) { + for (var deprecatedElement : applicationPackage.deploymentSpec().deprecatedElements()) { + if (applicationPackage.compileVersion().isEmpty()) continue; + if (deprecatedElement.majorVersion() >= applicationPackage.compileVersion().get().getMajor()) continue; + throw new IllegalArgumentException(deprecatedElement.humanReadableString()); + } } /** Verify that we have the security/clients.pem file for public systems */ diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java index f4f50de59d7..75abf94bf0e 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java @@ -1195,4 +1195,20 @@ public class ControllerTest { assertEquals(cloudAccount, tester.controllerTester().configServer().cloudAccount(context.deploymentIdIn(zone)).get().value()); } + @Test + public void testSubmitWithElementDeprecatedOnPreviousMajor() { + DeploymentContext context = tester.newDeploymentContext(); + var applicationPackage = new ApplicationPackageBuilder() + .compileVersion(Version.fromString("8.1")) + .region("us-west-1") + .globalServiceId("qrs") + .build(); + try { + context.submit(applicationPackage).deploy(); + fail("Expected exception"); + } catch (IllegalArgumentException e) { + assertTrue(e.getMessage().contains("Element 'prod' contains attribute 'global-service-id' deprecated since major version 7")); + } + } + } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java index 5d1a677bf51..490731ca06a 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/ApplicationPackageBuilder.java @@ -147,7 +147,10 @@ public class ApplicationPackageBuilder { } public ApplicationPackageBuilder region(String regionName) { - return region(RegionName.from(regionName), true); + prodBody.append(" <region>") + .append(regionName) + .append("</region>\n"); + return this; } public ApplicationPackageBuilder region(RegionName regionName, boolean active) { |