diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2022-01-11 11:50:01 +0100 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2022-01-11 11:51:07 +0100 |
commit | 5b0c591963d37d3e0bfa5f4cce09d6479cdaec5f (patch) | |
tree | 068e9a12d7c3a27742eb182aa5aab8dda1d14351 /controller-server | |
parent | 7121ee8a888e654d734aa93220dd9a6307e2e69b (diff) |
Hide apps without jobs in VersionStatus as well
Diffstat (limited to 'controller-server')
4 files changed, 23 insertions, 11 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationList.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationList.java index a6e53fead37..5c0669ad543 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationList.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationList.java @@ -61,6 +61,12 @@ public class ApplicationList extends AbstractFilteringList<Application, Applicat .anyMatch(deployment -> deployment.version().isBefore(version))); } + /** Returns the subset of applications with at least one declared job in deployment spec. */ + public ApplicationList withJobs() { + return matching(application -> application.deploymentSpec().steps().stream() + .anyMatch(step -> ! step.zones().isEmpty())); + } + /** Returns the subset of applications which have a project ID */ public ApplicationList withProjectId() { return matching(application -> application.projectId().isPresent()); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java index 24117b9f55f..b5008a44c6d 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java @@ -94,9 +94,7 @@ public class DeploymentApiHandler extends LoggingRequestHandler { Cursor platformArray = root.setArray("versions"); var versionStatus = controller.readVersionStatus(); var systemVersion = controller.systemVersion(versionStatus); - ApplicationList applications = ApplicationList.from(controller.applications().asList()) - .matching(application -> application.deploymentSpec().steps().stream() - .anyMatch(step -> ! step.zones().isEmpty())); + ApplicationList applications = ApplicationList.from(controller.applications().asList()).withJobs(); var deploymentStatuses = controller.jobController().deploymentStatuses(applications, systemVersion); var deploymentStatistics = DeploymentStatistics.compute(versionStatus.versions().stream().map(VespaVersion::versionNumber).collect(toList()), deploymentStatuses) diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/versions/VersionStatus.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/versions/VersionStatus.java index 24a739d4fc4..238ab0b09fa 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/versions/VersionStatus.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/versions/VersionStatus.java @@ -121,7 +121,8 @@ public class VersionStatus { List<DeploymentStatistics> deploymentStatistics = DeploymentStatistics.compute(infrastructureVersions.keySet(), controller.jobController().deploymentStatuses(ApplicationList.from(controller.applications().asList()) - .withProjectId())); + .withProjectId() + .withJobs())); List<VespaVersion> versions = new ArrayList<>(); List<Version> releasedVersions = controller.mavenRepository().metadata().versions(); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java index 61aab87532f..ca0db13b3d1 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiTest.java @@ -33,7 +33,7 @@ public class DeploymentApiTest extends ControllerContainerTest { public void testDeploymentApi() { ContainerTester tester = new ContainerTester(container, responseFiles); DeploymentTester deploymentTester = new DeploymentTester(new ControllerTester(tester)); - Version version = Version.fromString("5.0"); + Version version = Version.fromString("4.9"); deploymentTester.controllerTester().upgradeSystem(version); ApplicationPackage multiInstancePackage = new ApplicationPackageBuilder() .instances("i1,i2") @@ -42,14 +42,24 @@ public class DeploymentApiTest extends ControllerContainerTest { ApplicationPackage applicationPackage = new ApplicationPackageBuilder() .region("us-west-1") .build(); - ApplicationPackage emptyPackage = new ApplicationPackageBuilder().instances("custom").build(); + ApplicationPackage emptyPackage = new ApplicationPackageBuilder().instances("default") + .allow(ValidationId.deploymentRemoval) + .build(); - // 3 applications deploy on current system version, 1 is empty + // Deploy application without any declared jobs on the oldest version. + var oldAppWithoutDeployment = deploymentTester.newDeploymentContext("tenant4", "application4", "default"); + oldAppWithoutDeployment.submit().failDeployment(JobType.systemTest); + oldAppWithoutDeployment.submit(emptyPackage); + + // System upgrades to 5.0 for the other applications. + version = Version.fromString("5.0"); + deploymentTester.controllerTester().upgradeSystem(version); + + // 3 applications deploy on current system version. var failingApp = deploymentTester.newDeploymentContext("tenant1", "application1", "default"); var productionApp = deploymentTester.newDeploymentContext("tenant2", "application2", "i1"); var otherProductionApp = deploymentTester.newDeploymentContext("tenant2", "application2", "i2"); var appWithoutDeployments = deploymentTester.newDeploymentContext("tenant3", "application3", "default"); - var otherAppWithoutDeployment = deploymentTester.newDeploymentContext("tenant4", "application4", "custom"); failingApp.submit(applicationPackage).deploy(); productionApp.submit(multiInstancePackage).runJob(JobType.systemTest).runJob(JobType.stagingTest).runJob(JobType.productionUsWest1); otherProductionApp.runJob(JobType.productionUsWest1); @@ -58,9 +68,6 @@ public class DeploymentApiTest extends ControllerContainerTest { appWithoutDeployments.submit(applicationPackage).deploy(); appWithoutDeployments.submit(new ApplicationPackageBuilder().allow(ValidationId.deploymentRemoval).build()); - // Deploy application without any declared jobs. - otherAppWithoutDeployment.submit(emptyPackage); - // New version released version = Version.fromString("5.1"); deploymentTester.controllerTester().upgradeSystem(version); |