From 82a95a3663b704939a0c7ea49ed7a9d5e24bfd34 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@schedmd.com>
Date: Thu, 18 Apr 2013 12:25:30 -0700
Subject: [PATCH] Fix checking if QOS limit MaxCPUMinsPJ is set along with
 DenyOnLimit to deny the job instead of holding it.

---
 NEWS                        |  2 ++
 src/slurmctld/acct_policy.c | 29 ++++++++++++++---------------
 2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/NEWS b/NEWS
index fd51f887d2a..a3fde504e93 100644
--- a/NEWS
+++ b/NEWS
@@ -76,6 +76,8 @@ documents those changes that are of interest to users and admins.
  -- BGQ - fix for handling half rack system in STATIC of OVERLAP mode to
     implicitly create full system block.
  -- CRAY - Dynamically create BASIL XML buffer to resize as needed.
+ -- Fix checking if QOS limit MaxCPUMinsPJ is set along with DenyOnLimit to
+    deny the job instead of holding it.
 
 * Changes in Slurm 2.5.4
 ========================
diff --git a/src/slurmctld/acct_policy.c b/src/slurmctld/acct_policy.c
index 85d638d5658..24516713cf3 100644
--- a/src/slurmctld/acct_policy.c
+++ b/src/slurmctld/acct_policy.c
@@ -647,23 +647,22 @@ extern bool acct_policy_validate(job_desc_msg_t *job_desc,
 		 * if you can end up in PENDING QOSJobLimit, you need
 		 * to validate it if DenyOnLimit is set
 		 */
-		if (qos_ptr->max_cpu_mins_pj != INFINITE) {
+		if (strict_checking && (qos_ptr->max_cpu_mins_pj != INFINITE)
+		    && (job_desc->time_limit != NO_VAL)
+		    && (job_desc->min_cpus != NO_VAL)) {
 			cpu_time_limit = qos_ptr->max_cpu_mins_pj;
 			job_cpu_time_limit = (uint64_t)job_desc->time_limit
-					* (uint64_t)job_desc->min_cpus;
-			if (strict_checking && (job_desc->time_limit != NO_VAL) &&
-					(job_cpu_time_limit > cpu_time_limit)) {
-					if (reason)
-						*reason = WAIT_QOS_JOB_LIMIT;
-					debug2("job submit for user %s(%u): "
-								"cpu time limit %"PRIu64" exceeds "
-								"qos max per-job %"PRIu64"",
-								user_name,
-								job_desc->user_id,
-								job_cpu_time_limit,
-								cpu_time_limit);
-					rc = false;
-					goto end_it;
+				* (uint64_t)job_desc->min_cpus;
+			if (job_cpu_time_limit > cpu_time_limit) {
+				if (reason)
+					*reason = WAIT_QOS_JOB_LIMIT;
+				debug2("job submit for user %s(%u): "
+				       "cpu time limit %"PRIu64" exceeds "
+				       "qos max per-job %"PRIu64"",
+				       user_name, job_desc->user_id,
+				       job_cpu_time_limit, cpu_time_limit);
+				rc = false;
+				goto end_it;
 			}
 		}
 
-- 
GitLab