diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2020-02-20 09:16:35 +0100 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2020-02-20 09:16:35 +0100 |
commit | 5c7bd44ce8fdcf25d2ef2d614a9e724525366f6c (patch) | |
tree | cc429db6c9c62736cc3c90440212c8643bd0216f /controller-server | |
parent | 7a9cc89d9bde01cec32d6c3d6d67c6c51c840e6f (diff) |
Make sure we keep sending email when new run failre statuses are added
Diffstat (limited to 'controller-server')
-rw-r--r-- | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java | 35 |
1 files changed, 25 insertions, 10 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 9d666c6f7b5..cbce9ad48f1 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 @@ -38,6 +38,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.deployment.RunId; import com.yahoo.vespa.hosted.controller.api.integration.deployment.TesterCloud; import com.yahoo.vespa.hosted.controller.api.integration.deployment.TesterId; import com.yahoo.vespa.hosted.controller.api.integration.organization.DeploymentFailureMails; +import com.yahoo.vespa.hosted.controller.api.integration.organization.Mail; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.application.TenantAndApplicationId; @@ -672,22 +673,36 @@ public class InternalStepRunner implements StepRunner { return; try { - if (run.status() == outOfCapacity && run.id().type().isProduction()) - controller.serviceRegistry().mailer().send(mails.outOfCapacity(run.id(), recipients)); - if (run.status() == deploymentFailed) - controller.serviceRegistry().mailer().send(mails.deploymentFailure(run.id(), recipients)); - if (run.status() == installationFailed) - controller.serviceRegistry().mailer().send(mails.installationFailure(run.id(), recipients)); - if (run.status() == testFailure) - controller.serviceRegistry().mailer().send(mails.testFailure(run.id(), recipients)); - if (run.status() == error) - controller.serviceRegistry().mailer().send(mails.systemError(run.id(), recipients)); + mailOf(run, recipients).ifPresent(controller.serviceRegistry().mailer()::send); } catch (RuntimeException e) { logger.log(INFO, "Exception trying to send mail for " + run.id(), e); } } + private Optional<Mail> mailOf(Run run, List<String> recipients) { + switch (run.status()) { + case running: + case aborted: + case success: + return Optional.empty(); + case outOfCapacity: + return run.id().type().isProduction() ? Optional.of(mails.outOfCapacity(run.id(), recipients)) : Optional.empty(); + case deploymentFailed: + return Optional.of(mails.deploymentFailure(run.id(), recipients)); + case installationFailed: + return Optional.of(mails.installationFailure(run.id(), recipients)); + case testFailure: + return Optional.of(mails.testFailure(run.id(), recipients)); + case error: + case endpointCertificateTimeout: + return Optional.of(mails.systemError(run.id(), recipients)); + default: + logger.log(WARNING, "Don't know what mail to send for run status '" + run.status() + "'"); + return Optional.of(mails.systemError(run.id(), recipients)); + } + } + /** Returns the deployment of the real application in the zone of the given job, if it exists. */ private Optional<Deployment> deployment(ApplicationId id, JobType type) { return Optional.ofNullable(application(id).deployments().get(type.zone(controller.system()))); |