From bef2b9ebbeff7f4b7ffc70dc927b77f7d905c5b4 Mon Sep 17 00:00:00 2001
From: Morris Jette <jette@schedmd.com>
Date: Wed, 7 Jun 2017 13:19:39 -0600
Subject: [PATCH] Disable email job state notications except for pack leader

---
 doc/html/heterogeneous_jobs.shtml |  4 ++++
 src/slurmctld/proc_req.c          | 13 ++++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/doc/html/heterogeneous_jobs.shtml b/doc/html/heterogeneous_jobs.shtml
index 38a8c604c3f..99eec5c0d90 100644
--- a/doc/html/heterogeneous_jobs.shtml
+++ b/doc/html/heterogeneous_jobs.shtml
@@ -189,6 +189,10 @@ $ squeue --job=93
 JOBID PARTITION  NAME  USER ST  TIME  NODES NODELIST
 </pre>
 
+<p>Email notification for job state changes (the <i>--mail-type</i> option)
+is only supported for a pack leader. Requests for email notifications for other
+components of a heterogeneous job will be silently ignored.</p>
+
 <p>Requests to perform the following operations a job can only be requested for
 a pack leader and will be applied to all components of that heterogeneous job.
 Requests to operate on individual components of the heterogeneous will return
diff --git a/src/slurmctld/proc_req.c b/src/slurmctld/proc_req.c
index 82a63e65a7f..ea55baf701f 100644
--- a/src/slurmctld/proc_req.c
+++ b/src/slurmctld/proc_req.c
@@ -1278,6 +1278,11 @@ static void _slurm_rpc_allocate_pack(slurm_msg_t * msg)
 					       min_begin);
 		if (!job_desc_msg->resp_host)
 			job_desc_msg->resp_host = xstrdup(resp_host);
+		if (pack_job_offset) {
+			/* Email notifications disable except for pack leader */
+			job_desc_msg->mail_type = 0;
+			xfree(job_desc_msg->mail_user);
+		}
 		error_code = job_allocate(job_desc_msg, false, false, NULL,
 					  true, uid, &job_ptr, &err_msg,
 					  msg->protocol_version);
@@ -3917,10 +3922,16 @@ static void _slurm_rpc_submit_batch_pack_job(slurm_msg_t *msg)
 	START_TIMER;	/* Restart after we have locks */
 	iter = list_iterator_create(job_req_list);
 	while ((job_desc_msg = (job_desc_msg_t *) list_next(iter))) {
-		if (alloc_only && job_desc_msg->script) {
+		if (pack_job_offset && job_desc_msg->script) {
 			info("%s: Pack job %u offset %u has script, being ignord",
 			     __func__, pack_job_id, pack_job_offset);
 			xfree(job_desc_msg->script);
+
+		}
+		if (pack_job_offset) {
+			/* Email notifications disable except for pack leader */
+			job_desc_msg->mail_type = 0;
+			xfree(job_desc_msg->mail_user);
 		}
 		error_code = job_allocate(job_desc_msg,
 					  job_desc_msg->immediate, false,
-- 
GitLab