From 79f53494bab772747de3b4b65d1c3b33da7d2f30 Mon Sep 17 00:00:00 2001
From: David Bigagli <david@schedmd.com>
Date: Mon, 7 Jul 2014 12:21:46 -0700
Subject: [PATCH]  Set the job exit code when the job is signaled . Bug#941.

---
 NEWS                     | 2 ++
 src/slurmctld/job_mgr.c  | 5 ++++-
 src/slurmctld/proc_req.c | 6 +++---
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index 08804455562..e9888497144 100644
--- a/NEWS
+++ b/NEWS
@@ -54,6 +54,8 @@ documents those changes that are of interest to users and admins.
  -- If we cancel a task and we have no other exit code send the signal and
     exit code.
  -- Added note about InnoDB storage engine being used with MySQL.
+ -- Set the job exit code when the job is signaled and set the log level to debug2()
+    when processing an already completed job.
 
 * Changes in Slurm 14.03.4
 ==========================
diff --git a/src/slurmctld/job_mgr.c b/src/slurmctld/job_mgr.c
index a75edc090fe..ed0e55064f3 100644
--- a/src/slurmctld/job_mgr.c
+++ b/src/slurmctld/job_mgr.c
@@ -3809,8 +3809,11 @@ extern int job_complete(uint32_t job_id, uid_t uid, bool requeue,
 		return ESLURM_INVALID_JOB_ID;
 	}
 
-	if (IS_JOB_FINISHED(job_ptr))
+	if (IS_JOB_FINISHED(job_ptr)) {
+		if (job_ptr->exit_code == 0)
+			job_ptr->exit_code = job_return_code;
 		return ESLURM_ALREADY_DONE;
+	}
 
 	if ((job_ptr->user_id != uid) && !validate_slurm_user(uid)) {
 		error("Security violation, JOB_COMPLETE RPC for job %u "
diff --git a/src/slurmctld/proc_req.c b/src/slurmctld/proc_req.c
index 6feb3336a7f..0baa011c82a 100644
--- a/src/slurmctld/proc_req.c
+++ b/src/slurmctld/proc_req.c
@@ -1924,9 +1924,9 @@ static void _slurm_rpc_complete_batch_script(slurm_msg_t * msg)
 
 	/* return result */
 	if (error_code) {
-		info("_slurm_rpc_complete_batch_script JobId=%u: %s ",
-		     comp_msg->job_id,
-		     slurm_strerror(error_code));
+		debug2("_slurm_rpc_complete_batch_script JobId=%u: %s ",
+		       comp_msg->job_id,
+		       slurm_strerror(error_code));
 		slurm_send_rc_msg(msg, error_code);
 	} else {
 		debug2("_slurm_rpc_complete_batch_script JobId=%u %s",
-- 
GitLab