From fcc63508ad93f35e2fdedf0a4598bff9e1b9ef51 Mon Sep 17 00:00:00 2001
From: Morris Jette <jette@schedmd.com>
Date: Wed, 22 May 2013 14:47:02 -0700
Subject: [PATCH] Node reboot logic correction

Defers (rather than forgets) reboot request with job running on the
node within a reservation.
---
 NEWS                       |  2 ++
 src/slurmctld/controller.c | 13 +++++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index bd4906137fa..7b550ce06da 100644
--- a/NEWS
+++ b/NEWS
@@ -32,6 +32,8 @@ documents those changes that are of interest to users and admins.
  -- switch/nrt - Validate dynamic window allocation size.
  -- BGQ - When --geo is requested do not impose the default conn_types.
  -- CRAY - Support CLE 4.2.0
+ -- RebootNode logic - Defers (rather than forgets) reboot request with job
+    running on the node within a reservation.
 
 * Changes in Slurm 2.5.6
 ========================
diff --git a/src/slurmctld/controller.c b/src/slurmctld/controller.c
index f216d2aa495..f350c1ff4f6 100644
--- a/src/slurmctld/controller.c
+++ b/src/slurmctld/controller.c
@@ -1267,10 +1267,13 @@ static void _queue_reboot_msg(void)
 	want_nodes_reboot = false;
 	for (i = 0, node_ptr = node_record_table_ptr;
 	     i < node_record_count; i++, node_ptr++) {
-		if (!IS_NODE_MAINT(node_ptr) || /* do it only if node */
-		    is_node_in_maint_reservation(i)) /*isn't in reservation */
+		if (!IS_NODE_MAINT(node_ptr))
 			continue;
-		want_nodes_reboot = true; /* mark it for the next cycle */
+		if (is_node_in_maint_reservation(i)) {
+			/* defer if node isn't in reservation */
+			want_nodes_reboot = true;
+			continue;
+		}
 		if (IS_NODE_IDLE(node_ptr) && !IS_NODE_NO_RESPOND(node_ptr) &&
 		    !IS_NODE_POWER_UP(node_ptr)) /* only active idle nodes */
 			want_reboot = true;
@@ -1279,8 +1282,10 @@ static void _queue_reboot_msg(void)
 			want_reboot = true; /* system just restarted */
 		else
 			want_reboot = false;
-		if (!want_reboot)
+		if (!want_reboot) {
+			want_nodes_reboot = true;	/* defer reboot */
 			continue;
+		}
 		if (reboot_agent_args == NULL) {
 			reboot_agent_args = xmalloc(sizeof(agent_arg_t));
 			reboot_agent_args->msg_type = REQUEST_REBOOT_NODES;
-- 
GitLab