diff options
author | Valerij Fredriksen <freva@users.noreply.github.com> | 2022-06-15 20:01:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-15 20:01:39 +0200 |
commit | 28b57f1d58d2af4580cd41a9d2e08b5af63590b8 (patch) | |
tree | b6edd805dd02d89c0a26c77e544adc57c77ee77c /controller-server | |
parent | 5e94016f806f21548233865aa7bf0448aac2a387 (diff) | |
parent | 947c821385c7c2da8bad56d5e5dc88b76b709a45 (diff) |
Merge pull request #23118 from vespa-engine/jonmv/clean-up-apps-with-disabled-orchestration
Jonmv/clean up apps with disabled orchestration
Diffstat (limited to 'controller-server')
4 files changed, 20 insertions, 40 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 607a23e13bd..35eaa36cd2f 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 @@ -513,7 +513,7 @@ public class JobController { application = application.withProjectId(projectId == -1 ? OptionalLong.empty() : OptionalLong.of(projectId)); application = application.withRevisions(revisions -> revisions.with(version.get())); - application = withPrunedPackages(application); + application = withPrunedPackages(application, version.get().id()); TestSummary testSummary = TestPackage.validateTests(submission.applicationPackage().deploymentSpec(), submission.testPackage()); if (testSummary.problems().isEmpty()) @@ -536,21 +536,25 @@ public class JobController { }); applications.storeWithUpdatedConfig(application, submission.applicationPackage()); - applications.deploymentTrigger().triggerNewRevision(id); + if (application.get().projectId().isPresent()) + applications.deploymentTrigger().triggerNewRevision(id); }); return version.get(); } - private LockedApplication withPrunedPackages(LockedApplication application){ + private LockedApplication withPrunedPackages(LockedApplication application, RevisionId latest){ TenantAndApplicationId id = application.get().id(); - Optional<RevisionId> oldestDeployed = application.get().oldestDeployedRevision(); - if (oldestDeployed.isPresent()) { - controller.applications().applicationStore().prune(id.tenant(), id.application(), oldestDeployed.get()); - - for (ApplicationVersion version : application.get().revisions().withPackage()) - if (version.id().compareTo(oldestDeployed.get()) < 0) - application = application.withRevisions(revisions -> revisions.with(version.withoutPackage())); - } + Application wrapped = application.get(); + RevisionId oldestDeployed = application.get().oldestDeployedRevision() + .or(() -> wrapped.instances().values().stream() + .flatMap(instance -> instance.change().revision().stream()) + .min(naturalOrder())) + .orElse(latest); + controller.applications().applicationStore().prune(id.tenant(), id.application(), oldestDeployed); + + for (ApplicationVersion version : application.get().revisions().withPackage()) + if (version.id().compareTo(oldestDeployed) < 0) + application = application.withRevisions(revisions -> revisions.with(version.withoutPackage())); return application; } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployer.java index db9dc51ffa9..8a14dd3a146 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OutstandingChangeDeployer.java @@ -22,6 +22,7 @@ public class OutstandingChangeDeployer extends ControllerMaintainer { protected double maintain() { for (Application application : ApplicationList.from(controller().applications().readable()) .withProductionDeployment() + .withProjectId() .withDeploymentSpec() .asList()) controller().applications().deploymentTrigger().triggerNewRevision(application.id()); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java index c5d2dad20bc..2c0ab97c00e 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java @@ -797,13 +797,13 @@ public class ApplicationApiTest extends ControllerContainerTest { }, 200); - // GET application package for previous build + // GET application package for specific build tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/package", GET) - .properties(Map.of("build", "1")) + .properties(Map.of("build", "2")) .userIdentity(HOSTED_VESPA_OPERATOR), (response) -> { - assertEquals("attachment; filename=\"tenant1.application1-build1.zip\"", response.getHeaders().getFirst("Content-Disposition")); - assertArrayEquals(applicationPackageInstance1.zippedContent(), response.getBody()); + assertEquals("attachment; filename=\"tenant1.application1-build2.zip\"", response.getHeaders().getFirst("Content-Disposition")); + assertArrayEquals(packageWithService.zippedContent(), response.getBody()); }, 200); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment-overview.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment-overview.json index 81d363aa3e8..f39aab26d75 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment-overview.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment-overview.json @@ -47,14 +47,6 @@ "sourceUrl": "repository1/tree/commit1", "commit": "commit1" } - }, - { - "application": { - "build": 1, - "compileVersion": "6.1.0", - "sourceUrl": "repository1/tree/commit1", - "commit": "commit1" - } } ], "blockers": [ ] @@ -587,14 +579,6 @@ "sourceUrl": "repository1/tree/commit1", "commit": "commit1" } - }, - { - "application": { - "build": 1, - "compileVersion": "6.1.0", - "sourceUrl": "repository1/tree/commit1", - "commit": "commit1" - } } ], "blockers": [ ] @@ -707,15 +691,6 @@ "description": "my best commit yet", "risk": 9001, "deployable": false - }, - { - "build": 1, - "compileVersion": "6.1.0", - "sourceUrl": "repository1/tree/commit1", - "commit": "commit1", - "description": "my best commit yet", - "risk": 9001, - "deployable": true } ] } |