From 102f33f86dc3645fef161070b2c6aa779976c78e Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Wed, 3 Sep 2003 18:23:44 +0000
Subject: [PATCH] Fix default node selection for job step within DPCS initiated
 slurm job. It was picking zero nodes and failing.

---
 src/srun/job.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/srun/job.c b/src/srun/job.c
index cf8606b7c84..b063240b326 100644
--- a/src/srun/job.c
+++ b/src/srun/job.c
@@ -575,17 +575,15 @@ int    job_resp_hack_for_step(resource_allocation_response_msg_t *resp)
 	}
 
 	/* Add nodes as specified */
+	total = _job_resp_add_nodes(req_bitmap, exc_bitmap, resp->node_cnt);
 	if (opt.nodes_set) {
-		total = _job_resp_add_nodes(req_bitmap, exc_bitmap, 
-		                                resp->node_cnt);
 		if (total < opt.min_nodes) {
 			error("More nodes requested (%d) than available (%d)",
 				opt.min_nodes, total);
 			return_code = 1;
 			goto cleanup;
 		}
-	} else
-		total = bit_set_count(req_bitmap);
+	}
 
 	if (total != resp->node_cnt)
 		_job_resp_hack(resp, req_bitmap);
@@ -613,7 +611,12 @@ _job_resp_add_nodes(bitstr_t *req_bitmap, bitstr_t *exc_bitmap, int node_cnt)
 {
 	int inx, offset;
 	int total = bit_set_count(req_bitmap);
-	int max_nodes = MAX(opt.min_nodes, opt.max_nodes);
+	int max_nodes;
+
+	if (opt.nodes_set)
+		max_nodes = MAX(opt.min_nodes, opt.max_nodes);
+	else
+		max_nodes = node_cnt;
 
 	/* work up from first allocated node to first excluded node */
 	offset = bit_ffs(req_bitmap);
-- 
GitLab