From a9156dfd10b0b352e7cfb91bd42f885f813bbddf Mon Sep 17 00:00:00 2001
From: Morris Jette <jette@schedmd.com>
Date: Mon, 23 Apr 2012 14:50:57 -0700
Subject: [PATCH] Log duplicate node and partition names in slurm.conf

If a node or partition name is duplicated in slurm.conf, then log
it using error() and ignore the duplicate record. Update documentation
to be more clear
---
 doc/man/man5/slurm.conf.5   |  4 ++++
 src/common/node_conf.c      |  2 +-
 src/slurmctld/read_config.c | 12 +++++++-----
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/doc/man/man5/slurm.conf.5 b/doc/man/man5/slurm.conf.5
index 03c05b879ae..d627e2d426b 100644
--- a/doc/man/man5/slurm.conf.5
+++ b/doc/man/man5/slurm.conf.5
@@ -2227,6 +2227,8 @@ configuration file and the default values can be reset multiple times
 in the configuration file with multiple entries where "NodeName=DEFAULT".
 The "NodeName=" specification must be placed on every line
 describing the configuration of nodes.
+A single node name can not appear as a NodeName value in more than one line
+(duplicate node name records will be ignored).
 In fact, it is generally possible and desirable to define the
 configurations of all nodes in only a few lines.
 This convention permits significant optimization in the scheduling
@@ -2618,6 +2620,8 @@ configuration file and the default values can be reset multiple times
 in the configuration file with multiple entries where "PartitionName=DEFAULT".
 The "PartitionName=" specification must be placed on every line
 describing the configuration of partitions.
+A single partition name can not appear as a PartitionName value in more than
+one line (duplicate partition name records will be ignored).
 If a partition that is in use is deleted from the configuration and slurm
 is restarted or reconfigured (scontrol reconfigure), jobs using the partition
 are canceled.
diff --git a/src/common/node_conf.c b/src/common/node_conf.c
index cbd4ea4e501..ca16593d1eb 100644
--- a/src/common/node_conf.c
+++ b/src/common/node_conf.c
@@ -236,7 +236,7 @@ static int _build_single_nodeline_info(slurm_conf_node_t *node_ptr,
 			node_rec->reason    = xstrdup(node_ptr->reason);
 		} else {
 			/* FIXME - maybe should be fatal? */
-			error("reconfiguration for node %s, ignoring!", alias);
+			error("Reconfiguration for node %s, ignoring!", alias);
 		}
 		free(alias);
 	}
diff --git a/src/slurmctld/read_config.c b/src/slurmctld/read_config.c
index c8bf8c91597..0365a593863 100644
--- a/src/slurmctld/read_config.c
+++ b/src/slurmctld/read_config.c
@@ -494,8 +494,10 @@ static int _build_single_partitionline_info(slurm_conf_partition_t *part)
 		xfree(part_ptr->name);
 		part_ptr->name = xstrdup(part->name);
 	} else {
-		verbose("_parse_part_spec: duplicate entry for partition %s",
-			part->name);
+		/* FIXME - maybe should be fatal? */
+		error("_parse_part_spec: duplicate entry for partition %s, "
+		      "ignoring", part->name);
+		return EEXIST;
 	}
 
 	if (part->default_flag) {
@@ -514,7 +516,7 @@ static int _build_single_partitionline_info(slurm_conf_partition_t *part)
 	if (part->preempt_mode != (uint16_t) NO_VAL)
 		part_ptr->preempt_mode = part->preempt_mode;
 
-	if(part->disable_root_jobs == (uint16_t)NO_VAL) {
+	if (part->disable_root_jobs == (uint16_t)NO_VAL) {
 		if (slurmctld_conf.disable_root_jobs)
 			part_ptr->flags |= PART_FLAG_NO_ROOT;
 	} else if (part->disable_root_jobs) {
@@ -523,7 +525,7 @@ static int _build_single_partitionline_info(slurm_conf_partition_t *part)
 		part_ptr->flags &= (~PART_FLAG_NO_ROOT);
 	}
 
-	if(part_ptr->flags & PART_FLAG_NO_ROOT)
+	if (part_ptr->flags & PART_FLAG_NO_ROOT)
 		debug2("partition %s does not allow root jobs", part_ptr->name);
 
 	if ((part->default_time != NO_VAL) &&
@@ -593,7 +595,7 @@ static int _build_single_partitionline_info(slurm_conf_partition_t *part)
 			cnt_uniq = hostlist_count(hl);
 			if (cnt_tot != cnt_uniq) {
 				fatal("Duplicate Nodes for Partition %s",
-					part->name);
+				      part->name);
 			}
 			xfree(part_ptr->nodes);
 			part_ptr->nodes = hostlist_ranged_string_xmalloc(hl);
-- 
GitLab