diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-11-01 11:48:44 +0100 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-11-01 11:48:44 +0100 |
commit | 9989c141e42ba6cffbcd53ef54cc0d8880eeda8f (patch) | |
tree | dac5eca663ade7beb7f6e239d29e8d2c34e4f3de /controller-server | |
parent | f5eb888d310e546e2d98f9028e9c19833475ec5c (diff) |
Allow unregistering from internal deployment pipeline through application API
Diffstat (limited to 'controller-server')
5 files changed, 36 insertions, 4 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java index f046d23c5ce..c69fe5021e7 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java @@ -326,9 +326,18 @@ public class ApplicationController { ? triggered.sourceApplication().orElse(triggered.application()) : triggered.application(); - applicationPackage = application.get().deploymentJobs().deployedInternally() - ? new ApplicationPackage(applicationStore.getApplicationPackage(application.get().id(), applicationVersion.id())) - : new ApplicationPackage(artifactRepository.getApplicationPackage(application.get().id(), applicationVersion.id())); + try { + applicationPackage = application.get().deploymentJobs().deployedInternally() + ? new ApplicationPackage(applicationStore.getApplicationPackage(application.get().id(), applicationVersion.id())) + : new ApplicationPackage(artifactRepository.getApplicationPackage(application.get().id(), applicationVersion.id())); + } + catch (RuntimeException e) { // If application has switched deployment pipeline, artifacts stored prior to the switch are in the other artifact store. + log.info("Fetching application package for " + applicationId + " from alternate repository; it is now deployed " + + (application.get().deploymentJobs().deployedInternally() ? "internally" : "externally")); + applicationPackage = application.get().deploymentJobs().deployedInternally() + ? new ApplicationPackage(artifactRepository.getApplicationPackage(application.get().id(), applicationVersion.id())) + : new ApplicationPackage(applicationStore.getApplicationPackage(application.get().id(), applicationVersion.id())); + } validateRun(application.get(), zone, platformVersion, applicationVersion); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java index 4c6baece7f1..747e9d95558 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java @@ -214,6 +214,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler { if (path.matches("/application/v4/tenant/{tenant}")) return deleteTenant(path.get("tenant"), request); if (path.matches("/application/v4/tenant/{tenant}/application/{application}")) return deleteApplication(path.get("tenant"), path.get("application"), request); if (path.matches("/application/v4/tenant/{tenant}/application/{application}/deploying")) return cancelDeploy(path.get("tenant"), path.get("application")); + if (path.matches("/application/v4/tenant/{tenant}/application/{application}/submit")) return JobControllerApiHandlerHelper.unregisterResponse(controller.jobController(), path.get("tenant"), path.get("application")); if (path.matches("/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/job/{jobtype}")) return JobControllerApiHandlerHelper.abortJobResponse(controller.jobController(), appIdFromPath(path), jobTypeFromPath(path)); if (path.matches("/application/v4/tenant/{tenant}/application/{application}/environment/{environment}/region/{region}/instance/{instance}")) return deactivate(path.get("tenant"), path.get("application"), path.get("instance"), path.get("environment"), path.get("region"), request); if (path.matches("/application/v4/tenant/{tenant}/application/{application}/environment/{environment}/region/{region}/instance/{instance}/global-rotation/override")) diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java index 0d02c4003e7..34014f24862 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java @@ -421,5 +421,14 @@ class JobControllerApiHandlerHelper { return new SlimeJsonResponse(slime); } + /** Unregisters the application from the internal deployment pipeline. */ + static HttpResponse unregisterResponse(JobController jobs, String tenantName, String applicationName) { + ApplicationId id = ApplicationId.from(tenantName, applicationName, "default"); + jobs.unregister(id); + Slime slime = new Slime(); + slime.setObject().setString("message", "Unregistered '" + id + "' from internal deployment pipeline."); + return new SlimeJsonResponse(slime); + } + } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java index b87458e6ecf..e1a557f26f1 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java @@ -43,6 +43,7 @@ import static com.yahoo.vespa.hosted.controller.deployment.Step.Status.succeeded import static com.yahoo.vespa.hosted.controller.deployment.Step.Status.unfinished; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; /** * @author jonmv @@ -65,7 +66,7 @@ public class InternalStepRunnerTest { } @Test - public void canSwitchFromScrewdriver() { + public void canSwitchFromScrewdriverAndBackAgain() { // Deploys a default application package with default build number. tester.tester().deployCompletely(tester.app(), InternalDeploymentTester.applicationPackage); tester.setEndpoints(InternalDeploymentTester.appId, JobType.productionUsCentral1.zone(tester.tester().controller().system())); @@ -75,6 +76,14 @@ public class InternalStepRunnerTest { tester.deployNewSubmission(); tester.deployNewPlatform(new Version("7.1")); + + tester.jobs().unregister(InternalDeploymentTester.appId); + try { + tester.tester().deployCompletely(tester.app(), InternalDeploymentTester.applicationPackage, BuildJob.defaultBuildNumber + 1); + throw new IllegalStateException("Component job should get ahead again with build numbers to produce a change."); + } + catch (AssertionError expected) { } + tester.tester().deployCompletely(tester.app(), InternalDeploymentTester.applicationPackage, BuildJob.defaultBuildNumber + 2); } @Test 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 36d92620fa2..4192e4defdb 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 @@ -433,6 +433,10 @@ public class ApplicationApiTest extends ControllerContainerTest { .userIdentity(USER_ID), "{\"message\":\"Nothing to abort.\"}"); + tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/submit", DELETE) + .screwdriverIdentity(SCREWDRIVER_ID), + "{\"message\":\"Unregistered 'tenant1.application1' from internal deployment pipeline.\"}"); + // PUT (create) the authenticated user byte[] data = new byte[0]; tester.assertResponse(request("/application/v4/user?user=new_user&domain=by", PUT) |