summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Marius Venstad <jvenstad@yahoo-inc.com>2019-02-20 14:26:57 +0100
committerJon Marius Venstad <jvenstad@yahoo-inc.com>2019-02-20 14:26:57 +0100
commitf86887dc1f25c1fd7edaef7c5c32f6532828cff2 (patch)
tree912b7523afc28041f799f09b54bc02c287290c8c
parent34dac09e2b53529c3ac77de87bbe699e4f69a8dc (diff)
Send mail only when there are recipients
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java51
1 files changed, 26 insertions, 25 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java
index 51d4033044f..c1194244dd8 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java
@@ -453,31 +453,32 @@ public class InternalStepRunner implements StepRunner {
private void sendNotification(Run run, DualLogger logger) {
Application application = controller.applications().require(run.id().application());
Notifications notifications = application.deploymentSpec().notifications();
- if (notifications != Notifications.none()) {
- boolean newCommit = application.change().application()
- .map(run.versions().targetApplication()::equals)
- .orElse(false);
- When when = newCommit ? failingCommit : failing;
-
- List<String> recipients = new ArrayList<>(notifications.emailAddressesFor(when));
- if (notifications.emailRolesFor(when).contains(author))
- run.versions().targetApplication().authorEmail().ifPresent(recipients::add);
-
- try {
- if (run.status() == outOfCapacity && run.id().type().isProduction())
- controller.mailer().send(mails.outOfCapacity(run.id(), recipients));
- if (run.status() == deploymentFailed)
- controller.mailer().send(mails.deploymentFailure(run.id(), recipients));
- if (run.status() == installationFailed)
- controller.mailer().send(mails.installationFailure(run.id(), recipients));
- if (run.status() == testFailure)
- controller.mailer().send(mails.testFailure(run.id(), recipients));
- if (run.status() == error)
- controller.mailer().send(mails.systemError(run.id(), recipients));
- }
- catch (RuntimeException e) {
- logger.log(INFO, "Exception trying to send mail for " + run.id(), e);
- }
+ boolean newCommit = application.change().application()
+ .map(run.versions().targetApplication()::equals)
+ .orElse(false);
+ When when = newCommit ? failingCommit : failing;
+
+ List<String> recipients = new ArrayList<>(notifications.emailAddressesFor(when));
+ if (notifications.emailRolesFor(when).contains(author))
+ run.versions().targetApplication().authorEmail().ifPresent(recipients::add);
+
+ if (recipients.isEmpty())
+ return;
+
+ try {
+ if (run.status() == outOfCapacity && run.id().type().isProduction())
+ controller.mailer().send(mails.outOfCapacity(run.id(), recipients));
+ if (run.status() == deploymentFailed)
+ controller.mailer().send(mails.deploymentFailure(run.id(), recipients));
+ if (run.status() == installationFailed)
+ controller.mailer().send(mails.installationFailure(run.id(), recipients));
+ if (run.status() == testFailure)
+ controller.mailer().send(mails.testFailure(run.id(), recipients));
+ if (run.status() == error)
+ controller.mailer().send(mails.systemError(run.id(), recipients));
+ }
+ catch (RuntimeException e) {
+ logger.log(INFO, "Exception trying to send mail for " + run.id(), e);
}
}