aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2018-05-03 13:40:38 +0200
committerJon Marius Venstad <venstad@gmail.com>2018-05-03 13:40:38 +0200
commit623050bf9297c949a442d0e7f77a898a36700825 (patch)
tree8f9bc65e30199b7b288cc9c201748ea54fe27829 /controller-server
parent35ea83d9457566aff8bc539618bbbf718cc45581 (diff)
Add user which triggered job to its reason
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java6
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/screwdriver/ScrewdriverApiHandler.java8
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/screwdriver/ScrewdriverApiTest.java10
3 files changed, 10 insertions, 14 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java
index 92f53d362b5..bb9323ddbd8 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java
@@ -191,15 +191,15 @@ public class DeploymentTrigger {
}
}
- /** Force triggering of a job for given application */
- public List<JobType> forceTrigger(ApplicationId applicationId, JobType jobType) {
+ /** Force triggering of a job for given application. */
+ public List<JobType> forceTrigger(ApplicationId applicationId, JobType jobType, String user) {
Application application = applications().require(applicationId);
if (jobType == component) {
buildService.trigger(BuildJob.of(applicationId, application.deploymentJobs().projectId().getAsLong(), jobType.jobName()));
return singletonList(component);
}
Versions versions = versions(application, application.change(), deploymentFor(application, jobType));
- String reason = "Job triggered manually";
+ String reason = "Job triggered manually by " + user;
return (jobType.isProduction() && ! isTested(application, versions)
? testJobs(application, versions, reason, clock.instant()).stream()
: Stream.of(deploymentJob(application, versions, application.change(), jobType, reason, clock.instant())))
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
index 1ff67179d94..c1a2c575fc2 100644
--- 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
@@ -1,7 +1,6 @@
// 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.google.common.base.Joiner;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.container.jdisc.HttpResponse;
@@ -9,11 +8,9 @@ import com.yahoo.container.jdisc.LoggingRequestHandler;
import com.yahoo.jdisc.http.HttpRequest.Method;
import com.yahoo.slime.Cursor;
import com.yahoo.slime.Slime;
-import com.yahoo.vespa.hosted.controller.Application;
import com.yahoo.vespa.hosted.controller.Controller;
import com.yahoo.vespa.hosted.controller.api.integration.BuildService;
import com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType;
-import com.yahoo.vespa.hosted.controller.deployment.DeploymentTrigger;
import com.yahoo.vespa.hosted.controller.restapi.ErrorResponse;
import com.yahoo.vespa.hosted.controller.restapi.Path;
import com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse;
@@ -28,7 +25,6 @@ import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
-import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.joining;
/**
@@ -92,8 +88,8 @@ public class ScrewdriverApiHandler extends LoggingRequestHandler {
ApplicationId id = ApplicationId.from(tenantName, applicationName, "default");
String triggered = controller.applications().deploymentTrigger()
- .forceTrigger(id, jobType).stream()
- .map(JobType::jobName).collect(joining(", "));
+ .forceTrigger(id, jobType, request.getJDiscRequest().getUserPrincipal().getName())
+ .stream().map(JobType::jobName).collect(joining(", "));
Slime slime = new Slime();
Cursor cursor = slime.setObject();
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
index f49604c05cb..99274fd9f44 100644
--- 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
@@ -47,19 +47,19 @@ public class ScrewdriverApiTest extends ControllerContainerTest {
// Unknown application
assertResponse(new Request("http://localhost:8080/screwdriver/v1/trigger/tenant/foo/application/bar",
- new byte[0], Request.Method.POST),
+ 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),
+ "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),
+ new byte[0], Request.Method.POST, () -> "user"),
200, "{\"message\":\"Triggered component for tenant1.application1\"}");
tester.controller().applications().deploymentTrigger().notifyOfCompletion(new JobReport(app.id(),
DeploymentJobs.JobType.component,
@@ -71,13 +71,13 @@ public class ScrewdriverApiTest extends ControllerContainerTest {
// 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),
+ "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),
+ "production-us-east-3".getBytes(StandardCharsets.UTF_8), Request.Method.POST, () -> "user"),
200, "{\"message\":\"Triggered system-test for tenant1.application1\"}");
}