Warn early when user specifies illegal platform version for dev
@@ -685,6 +685,10 @@ public class JobController {
if ( ! controller.zoneRegistry().hasZone(type.zone()))
throw new IllegalArgumentException(type.zone() + " is not present in this system");
+ VersionStatus versionStatus = controller.readVersionStatus();
+ if (platform.isPresent() && versionStatus.deployableVersions().stream().map(VespaVersion::versionNumber).noneMatch(platform.get()::equals))
+ throw new IllegalArgumentException("platform version " + platform.get() + " is not present in this system");
+
controller.applications().lockApplicationOrThrow(TenantAndApplicationId.from(id), application -> {
if ( ! application.get().instances().containsKey(id.instance()))
application = controller.applications().withNewInstance(application, id);
@@ -706,7 +710,7 @@ public class JobController {
byte[] diff = getDiff(applicationPackage, deploymentId, lastRun);
controller.applications().lockApplicationOrThrow(TenantAndApplicationId.from(id), application -> {
- Version targetPlatform = platform.orElseGet(() -> findTargetPlatform(applicationPackage, deploymentId, application.get().get(id.instance())));
+ Version targetPlatform = platform.orElseGet(() -> findTargetPlatform(applicationPackage, deploymentId, application.get().get(id.instance()), versionStatus));
if ( ! allowOutdatedPlatform
&& ! controller.readVersionStatus().isOnCurrentMajor(targetPlatform)
&& runs(id, type).values().stream().noneMatch(run -> run.versions().targetPlatform().getMajor() == targetPlatform.getMajor()))
@@ -742,9 +746,8 @@ public class JobController {
.orElseGet(() -> ApplicationPackageDiff.diffAgainstEmpty(applicationPackage));
}
- private Version findTargetPlatform(ApplicationPackage applicationPackage, DeploymentId id, Optional<Instance> instance) {
+ private Version findTargetPlatform(ApplicationPackage applicationPackage, DeploymentId id, Optional<Instance> instance, VersionStatus versionStatus) {
// Prefer previous platform if possible. Candidates are all deployable, ascending, with existing version appended; then reversed.
- VersionStatus versionStatus = controller.readVersionStatus();
Version systemVersion = controller.systemVersion(versionStatus);
List<Version> versions = new ArrayList<>(List.of(systemVersion));
