From 3de7a0aaed8b2e4269515c54e53254979d0f6108 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@schedmd.com>
Date: Fri, 2 May 2014 12:16:25 -0700
Subject: [PATCH] Addendum to commit c6833796699f5956473e86118e18e5da95767ae5
 to handle situations where the association tree has multiple grp limits, only
 honor the first one.

---
 src/slurmctld/acct_policy.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/slurmctld/acct_policy.c b/src/slurmctld/acct_policy.c
index df06c2e2641..1465601b246 100644
--- a/src/slurmctld/acct_policy.c
+++ b/src/slurmctld/acct_policy.c
@@ -1949,18 +1949,28 @@ extern uint32_t acct_policy_get_max_nodes(struct job_record *job_ptr)
 
 	if (max_nodes_limit == INFINITE) {
 		slurmdb_association_rec_t *assoc_ptr = job_ptr->assoc_ptr;
-		int parent = 0; /*flag to tell us if we are looking at the
+		bool parent = 0; /*flag to tell us if we are looking at the
 				 * parent or not
 				 */
+		bool grp_set = 0;
 
 		while (assoc_ptr) {
-			max_nodes_limit =
-				MIN(max_nodes_limit, assoc_ptr->grp_nodes);
-			if (!parent)
+			if (assoc_ptr->grp_nodes != INFINITE) {
+				max_nodes_limit = MIN(max_nodes_limit,
+						      assoc_ptr->grp_nodes);
+				grp_set = 1;
+			}
+
+			if (!parent && (assoc_ptr->max_nodes_pj != INFINITE))
 				max_nodes_limit = MIN(max_nodes_limit,
 						      assoc_ptr->max_nodes_pj);
 
+			/* only check the first grp set */
+			if (grp_set)
+				break;
+
 			assoc_ptr = assoc_ptr->usage->parent_assoc_ptr;
+			parent = 1;
 			continue;
 		}
 
-- 
GitLab