diff options
10 files changed, 1 insertions, 227 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/ControllerAuthorizationFilter.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/ControllerAuthorizationFilter.java index 643bf462f13..309c37af341 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/ControllerAuthorizationFilter.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/ControllerAuthorizationFilter.java @@ -118,7 +118,6 @@ public class ControllerAuthorizationFilter extends CorsRequestFilterBase { if (isWhiteListedOperation(path, method)) return false; return path.matches("/controller/v1/{*}") || path.matches("/provision/v2/{*}") || - path.matches("/screwdriver/v1/trigger/tenant/{*}") || path.matches("/flags/v1/{*}") || path.matches("/os/v1/{*}") || path.matches("/zone/v2/{*}") || diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/screwdriver/ScrewdriverApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/screwdriver/ScrewdriverApiHandler.java deleted file mode 100644 index 05f889a7018..00000000000 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/screwdriver/ScrewdriverApiHandler.java +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.restapi.screwdriver; - -import com.yahoo.config.provision.ApplicationId; -import com.yahoo.container.jdisc.HttpRequest; -import com.yahoo.container.jdisc.HttpResponse; -import com.yahoo.container.jdisc.LoggingRequestHandler; -import com.yahoo.jdisc.http.HttpRequest.Method; -import com.yahoo.restapi.Path; -import com.yahoo.slime.Cursor; -import com.yahoo.slime.Slime; -import com.yahoo.vespa.hosted.controller.Controller; -import com.yahoo.vespa.hosted.controller.api.integration.BuildService; -import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; -import com.yahoo.vespa.hosted.controller.restapi.ErrorResponse; -import com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse; -import com.yahoo.yolean.Exceptions; - -import java.io.InputStream; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Scanner; -import java.util.logging.Level; -import java.util.logging.Logger; - -import static java.util.stream.Collectors.joining; - -// TODO jvenstad: Only useful method has been moved to application API. Delete this when users have updated. -/** - * This API lists deployment jobs that are queued for execution on Screwdriver. - * - * @author bratseth - * @author mpolden - */ -@SuppressWarnings("unused") // Handler -public class ScrewdriverApiHandler extends LoggingRequestHandler { - - private final static Logger log = Logger.getLogger(ScrewdriverApiHandler.class.getName()); - - private final Controller controller; - - public ScrewdriverApiHandler(LoggingRequestHandler.Context parentCtx, Controller controller) { - super(parentCtx); - this.controller = controller; - } - - @Override - public HttpResponse handle(HttpRequest request) { - Method method = request.getMethod(); - try { - switch (method) { - case GET: return get(request); - case POST: return post(request); - default: return ErrorResponse.methodNotAllowed("Method '" + method + "' is unsupported"); - } - } catch (IllegalArgumentException|IllegalStateException e) { - return ErrorResponse.badRequest(Exceptions.toMessageString(e)); - } catch (RuntimeException e) { - log.log(Level.WARNING, "Unexpected error handling '" + request.getUri() + "'", e); - return ErrorResponse.internalServerError(Exceptions.toMessageString(e)); - } - } - - private HttpResponse get(HttpRequest request) { - Path path = new Path(request.getUri().getPath()); - if (path.matches("/screwdriver/v1/jobsToRun")) { - return buildJobs(controller.applications().deploymentTrigger().jobsToRun()); - } - return notFound(request); - } - - private HttpResponse post(HttpRequest request) { - Path path = new Path(request.getUri().getPath()); - if (path.matches("/screwdriver/v1/trigger/tenant/{tenant}/application/{application}")) { - return trigger(request, path.get("tenant"), path.get("application")); - } - return notFound(request); - } - - private HttpResponse trigger(HttpRequest request, String tenantName, String applicationName) { - JobType jobType = Optional.of(asString(request.getData())) - .filter(s -> ! s.isEmpty()) - .map(JobType::fromJobName) - .orElse(JobType.component); - - ApplicationId id = ApplicationId.from(tenantName, applicationName, "default"); - String triggered = controller.applications().deploymentTrigger() - .forceTrigger(id, jobType, request.getJDiscRequest().getUserPrincipal().getName()) - .stream().map(JobType::jobName).collect(joining(", ")); - - Slime slime = new Slime(); - Cursor cursor = slime.setObject(); - String message = triggered.isEmpty() - ? "Job " + jobType.jobName() + " for " + id + " not triggered" - : "Triggered " + triggered + " for " + id; - cursor.setString("message", message); - return new SlimeJsonResponse(slime); - } - - private HttpResponse buildJobs(Map<JobType, ? extends List<? extends BuildService.BuildJob>> jobLists) { - Slime slime = new Slime(); - Cursor jobTypesObject = slime.setObject(); - jobLists.forEach((jobType, jobs) -> { - Cursor jobArray = jobTypesObject.setArray(jobType.jobName()); - jobs.forEach(job -> { - Cursor buildJobObject = jobArray.addObject(); - buildJobObject.setString("applicationId", job.applicationId().toString()); - buildJobObject.setLong("projectId", job.projectId()); - }); - }); - return new SlimeJsonResponse(slime); - } - - private static String asString(InputStream in) { - Scanner scanner = new Scanner(in).useDelimiter("\\A"); - if (scanner.hasNext()) { - return scanner.next(); - } - return ""; - } - - private static HttpResponse notFound(HttpRequest request) { - return ErrorResponse.notFoundError(String.format("No '%s' handler at '%s'", request.getMethod(), - request.getUri().getPath())); - } - -} diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java index 3179e353f50..833eb46b675 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java @@ -116,9 +116,6 @@ public class ControllerContainerTest { " <handler id='com.yahoo.vespa.hosted.controller.restapi.cost.CostApiHandler'>\n" + " <binding>http://*/cost/v1/*</binding>\n" + " </handler>\n" + - " <handler id='com.yahoo.vespa.hosted.controller.restapi.screwdriver.ScrewdriverApiHandler'>\n" + - " <binding>http://*/screwdriver/v1/*</binding>\n" + - " </handler>\n" + " <handler id='com.yahoo.vespa.hosted.controller.restapi.zone.v1.ZoneApiHandler'>\n" + " <binding>http://*/zone/v1</binding>\n" + " <binding>http://*/zone/v1/*</binding>\n" + 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 dc389704b69..a6573f61c29 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 @@ -2,7 +2,6 @@ package com.yahoo.vespa.hosted.controller.restapi.application; import com.yahoo.application.container.handler.Request; -import com.yahoo.application.container.handler.Response; import com.yahoo.component.Version; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.AthenzService; @@ -13,7 +12,6 @@ import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.RotationName; import com.yahoo.config.provision.TenantName; import com.yahoo.slime.Cursor; -import com.yahoo.slime.Inspector; import com.yahoo.slime.Slime; import com.yahoo.vespa.athenz.api.AthenzDomain; import com.yahoo.vespa.athenz.api.AthenzIdentity; @@ -1267,13 +1265,7 @@ public class ApplicationApiTest extends ControllerContainerTest { recordedStatus = tester.controller().applications().get(app.id()).get().deploymentJobs().jobStatus().get(JobType.productionApNortheast2); assertNull("Status of never-triggered jobs is empty", recordedStatus); - - Response response; - - response = container.handleRequest(request("/screwdriver/v1/jobsToRun", GET).get()); - Inspector jobs = SlimeUtils.jsonToSlime(response.getBody()).get(); - assertEquals("Response contains no items, as all jobs are triggered", 0, jobs.children()); - + assertTrue("All jobs have been run", tester.controller().applications().deploymentTrigger().jobsToRun().isEmpty()); } @Test diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/cookiefreshness.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/cookiefreshness.json deleted file mode 100644 index 3c428332aa6..00000000000 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/cookiefreshness.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "shouldRefreshCookie":true -}
\ No newline at end of file diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/delete-tenant-response.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/delete-tenant-response.json deleted file mode 100644 index e69de29bb2d..00000000000 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/delete-tenant-response.json +++ /dev/null diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deploy-error-result.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deploy-error-result.json deleted file mode 100644 index f9496edecde..00000000000 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deploy-error-result.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "error-code":"BAD_REQUEST", - "message":"Failed to prepare application" -}
\ No newline at end of file diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/tenant-without-applications-underscore.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/tenant-without-applications-underscore.json deleted file mode 100644 index 243d5fb20c6..00000000000 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/tenant-without-applications-underscore.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "tenant": "my_tenant_2", - "type": "ATHENS", - "athensDomain": "domain1", - "property": "property1", - "applications": [ - - ] -} diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/filter/ControllerAuthorizationFilterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/filter/ControllerAuthorizationFilterTest.java index 9b7c36c49e1..1dc0e14d447 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/filter/ControllerAuthorizationFilterTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/filter/ControllerAuthorizationFilterTest.java @@ -71,8 +71,6 @@ public class ControllerAuthorizationFilterTest { testApiAccess(PUT, "/zone/v2/hello-proxy-path", allowed, forbidden, filter); - testApiAccess(POST, "/screwdriver/v1/trigger/tenant/mytenant/application/myapp/", - allowed, forbidden, filter); testApiAccess(DELETE, "/provision/v2/provision/enqueue", allowed, forbidden, filter); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/screwdriver/ScrewdriverApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/screwdriver/ScrewdriverApiTest.java deleted file mode 100644 index 68d08dc9769..00000000000 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/screwdriver/ScrewdriverApiTest.java +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.restapi.screwdriver; - -import com.yahoo.application.container.handler.Request; -import com.yahoo.vespa.hosted.controller.Application; -import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; -import com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobReport; -import com.yahoo.vespa.hosted.controller.api.integration.deployment.SourceRevision; -import com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester; -import com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest; -import org.junit.Test; - -import java.nio.charset.StandardCharsets; -import java.util.Optional; -import java.util.OptionalLong; - -/** - * @author bratseth - * @author jonmv - */ -public class ScrewdriverApiTest extends ControllerContainerTest { - - @Test - public void testTriggerJobForApplication() { - ContainerControllerTester tester = new ContainerControllerTester(container, null); - tester.containerTester().computeVersionStatus(); - - Application app = tester.createApplication(); - tester.controller().applications().lockOrThrow(app.id(), application -> - tester.controller().applications().store(application.withProjectId(OptionalLong.of(1L)))); - - // Unknown application - assertResponse(new Request("http://localhost:8080/screwdriver/v1/trigger/tenant/foo/application/bar", - new byte[0], Request.Method.POST, () -> "user"), - 400, "{\"error-code\":\"BAD_REQUEST\",\"message\":\"foo.bar not found\"}"); - - // Invalid job - assertResponse(new Request("http://localhost:8080/screwdriver/v1/trigger/tenant/" + - app.id().tenant().value() + "/application/" + app.id().application().value(), - "invalid".getBytes(StandardCharsets.UTF_8), Request.Method.POST, () -> "user"), - 400, "{\"error-code\":\"BAD_REQUEST\",\"message\":\"Unknown job name 'invalid'\"}"); - - // component is triggered if no job is specified in request body - assertResponse(new Request("http://localhost:8080/screwdriver/v1/trigger/tenant/" + - app.id().tenant().value() + "/application/" + app.id().application().value(), - new byte[0], Request.Method.POST, () -> "user"), - 200, "{\"message\":\"Triggered component for tenant1.application1\"}"); - tester.controller().applications().deploymentTrigger().notifyOfCompletion(JobReport.ofComponent(app.id(), - 1, - 42, - Optional.empty(), - new SourceRevision("repo", "branch", "commit"))); - - // Triggers specific job when given, when job is a test, or tested. - assertResponse(new Request("http://localhost:8080/screwdriver/v1/trigger/tenant/" + - app.id().tenant().value() + "/application/" + app.id().application().value(), - "staging-test".getBytes(StandardCharsets.UTF_8), Request.Method.POST, () -> "user"), - 200, "{\"message\":\"Triggered staging-test for tenant1.application1\"}"); - - // Triggers test jobs (only system-test here since deployment spec is unknown) when given untested production job. - assertResponse(new Request("http://localhost:8080/screwdriver/v1/trigger/tenant/" + - app.id().tenant().value() + "/application/" + app.id().application().value(), - "production-us-east-3".getBytes(StandardCharsets.UTF_8), Request.Method.POST, () -> "user"), - 200, "{\"message\":\"Triggered system-test for tenant1.application1\"}"); - - } - -} |