diff options
author | jonmv <venstad@gmail.com> | 2022-06-17 09:33:05 +0200 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2022-06-17 09:33:05 +0200 |
commit | 6b1809751e7d0f0a21b983a2f90330db7d6f9c0d (patch) | |
tree | 3f1284acf98e0167bf9d14db83062d126b9bfd5f /controller-server | |
parent | 28b57f1d58d2af4580cd41a9d2e08b5af63590b8 (diff) |
Improve error messages for wrong version setup for dev deployments
Diffstat (limited to 'controller-server')
2 files changed, 28 insertions, 16 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java index 35eaa36cd2f..316cf2de2d4 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java @@ -41,6 +41,7 @@ import java.security.cert.X509Certificate; import java.time.Duration; import java.time.Instant; import java.util.ArrayDeque; +import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Deque; @@ -668,14 +669,6 @@ public class JobController { } private Version findTargetPlatform(ApplicationPackage applicationPackage, DeploymentId id, Optional<Instance> instance) { - Optional<Integer> major = applicationPackage.deploymentSpec().majorVersion(); - if (major.isPresent()) - return controller.applications().lastCompatibleVersion(major.get()) - .orElseThrow(() -> new IllegalArgumentException("major " + major.get() + " specified in deployment.xml, " + - "but no version on this major was found")); - - VersionCompatibility compatibility = controller.applications().versionCompatibility(id.applicationId()); - // Prefer previous platform if possible. Candidates are all deployable, ascending, with existing version appended; then reversed. List<Version> versions = controller.readVersionStatus().deployableVersions().stream() .map(VespaVersion::versionNumber) @@ -685,14 +678,33 @@ public class JobController { .map(Deployment::version) .ifPresent(versions::add); + if (versions.isEmpty()) + throw new IllegalStateException("no deployable platform version found in the system"); + + VersionCompatibility compatibility = controller.applications().versionCompatibility(id.applicationId()); + List<Version> compatibleVersions = new ArrayList<>(); for (Version target : reversed(versions)) if (applicationPackage.compileVersion().isEmpty() || compatibility.accept(target, applicationPackage.compileVersion().get())) + compatibleVersions.add(target); + + if (compatibleVersions.isEmpty()) + throw new IllegalArgumentException("no platforms are compatible with compile version " + applicationPackage.compileVersion().get()); + + Optional<Integer> major = applicationPackage.deploymentSpec().majorVersion(); + List<Version> versionOnRightMajor = new ArrayList<>(); + for (Version target : reversed(versions)) + if (major.isEmpty() || major.get() == target.getMajor()) + versionOnRightMajor.add(target); + + if (versionOnRightMajor.isEmpty()) + throw new IllegalArgumentException("no platforms were found for major version " + major.get() + " specified in deployment.xml"); + + for (Version target : compatibleVersions) + if (versionOnRightMajor.contains(target)) return target; - throw new IllegalArgumentException("no suitable platform version found" + - applicationPackage.compileVersion() - .map(version -> " for package compiled against " + version) - .orElse("")); + throw new IllegalArgumentException("no platforms on major version " + major.get() + " specified in deployment.xml " + + "are compatible with compile version " + applicationPackage.compileVersion().get()); } /** Aborts a run and waits for it complete. */ 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 8ce55fa5f1b..28536f36e20 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 @@ -748,15 +748,15 @@ public class ControllerTest { fail("Should fail when specifying a major that does not yet exist"); } catch (IllegalArgumentException e) { - assertEquals("major 8 specified in deployment.xml, but no version on this major was found", e.getMessage()); + assertEquals("no platforms were found for major version 8 specified in deployment.xml", e.getMessage()); } try { context.runJob(zone, new ApplicationPackageBuilder().compileVersion(version3).build()); - fail("Should fail when compiled against a version which does not yet exist"); + fail("Should fail when compiled against a version which is only compatible with not-yet-existent versions"); } catch (IllegalArgumentException e) { - assertEquals("no suitable platform version found for package compiled against 8", e.getMessage()); + assertEquals("no platforms are compatible with compile version 8", e.getMessage()); } tester.controllerTester().upgradeSystem(version3); @@ -765,7 +765,7 @@ public class ControllerTest { fail("Should fail when specifying a major which is incompatible with compile version"); } catch (IllegalArgumentException e) { - assertEquals("Will not start dev-us-east-1 for tenant.application with incompatible platform version (8) and compile versions (7)", e.getMessage()); + assertEquals("no platforms on major version 8 specified in deployment.xml are compatible with compile version 7", e.getMessage()); } context.runJob(zone, new ApplicationPackageBuilder().compileVersion(version3).majorVersion(8).build()); |