From d0453c8f36a0fc2544bbf844de45772cb4d69275 Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Thu, 15 May 2008 20:48:32 +0000
Subject: [PATCH] Insure that nodes select in "srun --will-run" command or the
 equivalent in     sched/wiki2 are in the job's partition.

---
 NEWS                                   |  2 ++
 src/plugins/sched/wiki2/job_will_run.c | 18 +++++++++++++++---
 src/slurmctld/job_scheduler.c          | 12 +++++++++---
 3 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/NEWS b/NEWS
index ea864cc3978..187f2c92abd 100644
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,8 @@ documents those changes that are of interest to users and admins.
  -- Fix bug in processing job feature requests with node counts (could fail
     to schedule job if some nodes have not associated features).
  -- Added nodecnt and gid to jobcomp/script
+ -- Insure that nodes select in "srun --will-run" command or the equivalent in
+    sched/wiki2 are in the job's partition.
 
 * Changes in SLURM 1.3.1
 ========================
diff --git a/src/plugins/sched/wiki2/job_will_run.c b/src/plugins/sched/wiki2/job_will_run.c
index 6cf1cec7d95..3ecca4dfd06 100644
--- a/src/plugins/sched/wiki2/job_will_run.c
+++ b/src/plugins/sched/wiki2/job_will_run.c
@@ -206,10 +206,22 @@ static char *	_will_run_test(uint32_t *jobid, time_t *start_time,
 			error("wiki: Attempt to set invalid available node "
 			      "list for job %u, %s", jobid[i], node_list[i]);
 			break;
-		} else {
-			/* Only consider nodes that are not DOWN or DRAINED */
-			bit_and(avail_bitmap, avail_node_bitmap);
 		}
+
+		/* Only consider nodes that are not DOWN or DRAINED */
+		bit_and(avail_bitmap, avail_node_bitmap);
+
+		/* Consider only nodes in this job's partition */
+		if (part_ptr->node_bitmap)
+			bit_and(avail_bitmap, part_ptr->node_bitmap);
+		else {
+			*err_code = -730;
+			*err_msg = "Job's partition has no nodes";
+			error("wiki: no nodes in partition %s for job %u", 
+				part_ptr->name, jobid[i]);
+			break;
+		}
+
 		if (job_req_node_filter(job_ptr, avail_bitmap) != 
 		    SLURM_SUCCESS) {
 			/* Job probably has invalid feature list */
diff --git a/src/slurmctld/job_scheduler.c b/src/slurmctld/job_scheduler.c
index 9cf46f13563..0f7d6dc324b 100644
--- a/src/slurmctld/job_scheduler.c
+++ b/src/slurmctld/job_scheduler.c
@@ -791,11 +791,17 @@ extern int job_start_data(job_desc_msg_t *job_desc_msg,
 	} else if (node_name2bitmap(job_desc_msg->req_nodes, false, 
 				    &avail_bitmap) != 0) {
 		return ESLURM_INVALID_NODE_NAME;
-	} else {
-		/* Only consider nodes that are not DOWN or DRAINED */
-		bit_and(avail_bitmap, avail_node_bitmap);
 	}
 
+	/* Only consider nodes that are not DOWN or DRAINED */
+	bit_and(avail_bitmap, avail_node_bitmap);
+
+	/* Consider only nodes in this job's partition */
+	if (part_ptr->node_bitmap)
+		bit_and(avail_bitmap, part_ptr->node_bitmap);
+	else
+		rc = ESLURM_REQUESTED_PART_CONFIG_UNAVAILABLE;
+
 	if (job_req_node_filter(job_ptr, avail_bitmap))
 		rc = ESLURM_REQUESTED_PART_CONFIG_UNAVAILABLE;
 	if (job_ptr->details->exc_node_bitmap) {
-- 
GitLab