Make sure we keep sending email when new run failre statuses are added
@@ -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())));
