From 88f64c5e15d3b4fca2e4d29a83252c6bc7adcc39 Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Fri, 4 Mar 2011 22:15:11 +0000
Subject: [PATCH] avoid printing an error from sview if it reads configuration
 parameters that it does not recognize. The options may be from a newer
 version of sview.

---
 src/common/gres.c                            |  2 +-
 src/common/parse_config.c                    | 29 ++++++++++++++------
 src/common/parse_config.h                    |  5 +++-
 src/common/read_config.c                     |  4 +--
 src/plugins/proctrack/cgroup/read_config.c   |  3 +-
 src/plugins/sched/wiki/msg.c                 |  2 +-
 src/plugins/sched/wiki2/msg.c                |  2 +-
 src/plugins/select/bluegene/bg_read_config.c |  2 +-
 src/plugins/switch/federation/federation.c   |  2 +-
 src/plugins/topology/tree/topology_tree.c    |  3 +-
 src/slurmdbd/read_config.c                   |  3 +-
 src/smap/configure_functions.c               |  2 +-
 src/sview/defaults.c                         |  2 +-
 src/sview/sview.c                            | 26 +++++++++++++++++-
 14 files changed, 64 insertions(+), 23 deletions(-)

diff --git a/src/common/gres.c b/src/common/gres.c
index 897251b1522..fb8f524059e 100644
--- a/src/common/gres.c
+++ b/src/common/gres.c
@@ -763,7 +763,7 @@ extern int gres_plugin_node_config_load(uint32_t cpu_cnt)
 	if (stat(gres_conf_file, &config_stat) < 0)
 		fatal("can't stat gres.conf file %s: %m", gres_conf_file);
 	tbl = s_p_hashtbl_create(_gres_options);
-	if (s_p_parse_file(tbl, NULL, gres_conf_file) == SLURM_ERROR)
+	if (s_p_parse_file(tbl, NULL, gres_conf_file, false) == SLURM_ERROR)
 		fatal("error opening/reading %s", gres_conf_file);
 	gres_conf_list = list_create(_destroy_gres_slurmd_conf);
 	if (gres_conf_list == NULL)
diff --git a/src/common/parse_config.c b/src/common/parse_config.c
index 1651fa9338a..c186662ce97 100644
--- a/src/common/parse_config.c
+++ b/src/common/parse_config.c
@@ -767,9 +767,10 @@ int s_p_parse_line(s_p_hashtbl_t *hashtbl, const char *line, char **leftover)
 
 /*
  * Returns 1 if the line is parsed cleanly, and 0 otherwise.
+ * IN ingore_new - if set do not treat unrecongized input as a fatal error
  */
 static int _parse_next_key(s_p_hashtbl_t *hashtbl,
-			   const char *line, char **leftover)
+			   const char *line, char **leftover, bool ignore_new)
 {
 	char *key, *value;
 	s_p_values_t *p;
@@ -782,6 +783,9 @@ static int _parse_next_key(s_p_hashtbl_t *hashtbl,
 			_handle_keyvalue_match(p, value,
 					       new_leftover, &new_leftover);
 			*leftover = new_leftover;
+		} else if (ignore_new) {
+			debug("Parsing error at unrecognized key: %s", key);
+			*leftover = (char *)line;
 		} else {
 			error("Parsing error at unrecognized key: %s", key);
 			xfree(key);
@@ -805,7 +809,8 @@ static int _parse_next_key(s_p_hashtbl_t *hashtbl,
  * no include directive is found.
  */
 static int _parse_include_directive(s_p_hashtbl_t *hashtbl, uint32_t *hash_val,
-				    const char *line, char **leftover)
+				    const char *line, char **leftover,
+				    bool ignore_new)
 {
 	char *ptr;
 	char *fn_start, *fn_stop;
@@ -823,7 +828,7 @@ static int _parse_include_directive(s_p_hashtbl_t *hashtbl, uint32_t *hash_val,
 			ptr++;
 		fn_stop = *leftover = ptr;
 		filename = xstrndup(fn_start, fn_stop-fn_start);
-		if (s_p_parse_file(hashtbl, hash_val, filename)
+		if (s_p_parse_file(hashtbl, hash_val, filename, ignore_new)
 		    == SLURM_SUCCESS) {
 			xfree(filename);
 			return 1;
@@ -836,7 +841,8 @@ static int _parse_include_directive(s_p_hashtbl_t *hashtbl, uint32_t *hash_val,
 	}
 }
 
-int s_p_parse_file(s_p_hashtbl_t *hashtbl, uint32_t *hash_val, char *filename)
+int s_p_parse_file(s_p_hashtbl_t *hashtbl, uint32_t *hash_val, char *filename,
+		   bool ignore_new)
 {
 	FILE *f;
 	char line[BUFFER_SIZE];
@@ -878,9 +884,9 @@ int s_p_parse_file(s_p_hashtbl_t *hashtbl, uint32_t *hash_val, char *filename)
 		}
 
 		inc_rc = _parse_include_directive(hashtbl, hash_val,
-						  line, &leftover);
+						  line, &leftover, ignore_new);
 		if (inc_rc == 0) {
-			_parse_next_key(hashtbl, line, &leftover);
+			_parse_next_key(hashtbl, line, &leftover, ignore_new);
 		} else if (inc_rc < 0) {
 			error("\"Include\" failed in file %s line %d",
 			      filename, line_number);
@@ -893,10 +899,15 @@ int s_p_parse_file(s_p_hashtbl_t *hashtbl, uint32_t *hash_val, char *filename)
 		if (!_line_is_space(leftover)) {
 			char *ptr = xstrdup(leftover);
 			_strip_cr_nl(ptr);
-			error("Parse error in file %s line %d: \"%s\"",
-			      filename, line_number, ptr);
+			if (ignore_new) {
+				debug("Parse error in file %s line %d: \"%s\"",
+				      filename, line_number, ptr);
+			} else {
+				error("Parse error in file %s line %d: \"%s\"",
+				      filename, line_number, ptr);
+				rc = SLURM_ERROR;
+			}
 			xfree(ptr);
-			rc = SLURM_ERROR;
 		}
 		line_number += merged_lines;
 	}
diff --git a/src/common/parse_config.h b/src/common/parse_config.h
index 571b9bee1ab..fb5fc6a24f7 100644
--- a/src/common/parse_config.h
+++ b/src/common/parse_config.h
@@ -182,8 +182,11 @@ void s_p_hashtbl_destroy(s_p_hashtbl_t *hashtbl);
 /* Returns SLURM_SUCCESS if file was opened and parse correctly
  * OUT hash_val - cyclic redundancy check (CRC) character-wise value
  *                of file.
+ * IN ignore_new - do not treat unrecognized keywords as a fatal error,
+ *                 print debug() message and continue
  */
-int s_p_parse_file(s_p_hashtbl_t *hashtbl, uint32_t *hash_val, char *filename);
+int s_p_parse_file(s_p_hashtbl_t *hashtbl, uint32_t *hash_val, char *filename,
+		   bool ignore_new);
 
 /*
  * Returns 1 if the line is parsed cleanly, and 0 otherwise.
diff --git a/src/common/read_config.c b/src/common/read_config.c
index add904432a5..c8d258209cc 100644
--- a/src/common/read_config.c
+++ b/src/common/read_config.c
@@ -1956,8 +1956,8 @@ static void _init_slurm_conf(const char *file_name)
 
 	/* init hash to 0 */
 	conf_ptr->hash_val = 0;
-	if(s_p_parse_file(conf_hashtbl, &conf_ptr->hash_val, name)
-	   == SLURM_ERROR)
+	if (s_p_parse_file(conf_hashtbl, &conf_ptr->hash_val, name, false)
+	    == SLURM_ERROR)
 		fatal("something wrong with opening/reading conf file");
 	/* s_p_dump_values(conf_hashtbl, slurm_conf_options); */
 	_validate_and_set_defaults(conf_ptr, conf_hashtbl);
diff --git a/src/plugins/proctrack/cgroup/read_config.c b/src/plugins/proctrack/cgroup/read_config.c
index 21fcc82ae3a..4e4296f8652 100644
--- a/src/plugins/proctrack/cgroup/read_config.c
+++ b/src/plugins/proctrack/cgroup/read_config.c
@@ -130,7 +130,8 @@ extern int read_slurm_cgroup_conf(void)
 		debug("Reading cgroup.conf file %s", conf_path);
 
 		tbl = s_p_hashtbl_create(options);
-		if (s_p_parse_file(tbl, NULL, conf_path) == SLURM_ERROR) {
+		if (s_p_parse_file(tbl, NULL, conf_path, false) ==
+		    SLURM_ERROR) {
 			fatal("Could not open/read/parse cgroup.conf file %s",
 			      conf_path);
 		}
diff --git a/src/plugins/sched/wiki/msg.c b/src/plugins/sched/wiki/msg.c
index 17f435bb2fa..39eabdc94df 100644
--- a/src/plugins/sched/wiki/msg.c
+++ b/src/plugins/sched/wiki/msg.c
@@ -285,7 +285,7 @@ extern int parse_wiki_config(void)
 
 	debug("Reading wiki.conf file (%s)",wiki_conf);
 	tbl = s_p_hashtbl_create(options);
-	if (s_p_parse_file(tbl, NULL, wiki_conf) == SLURM_ERROR)
+	if (s_p_parse_file(tbl, NULL, wiki_conf, false) == SLURM_ERROR)
 		fatal("something wrong with opening/reading wiki.conf file");
 
 	if (! s_p_get_string(&key, "AuthKey", tbl))
diff --git a/src/plugins/sched/wiki2/msg.c b/src/plugins/sched/wiki2/msg.c
index efe23ac2aa0..e8e0c3bc5f6 100644
--- a/src/plugins/sched/wiki2/msg.c
+++ b/src/plugins/sched/wiki2/msg.c
@@ -292,7 +292,7 @@ extern int parse_wiki_config(void)
 
 	debug("Reading wiki.conf file (%s)",wiki_conf);
 	tbl = s_p_hashtbl_create(options);
-	if (s_p_parse_file(tbl, NULL, wiki_conf) == SLURM_ERROR)
+	if (s_p_parse_file(tbl, NULL, wiki_conf, false) == SLURM_ERROR)
 		fatal("something wrong with opening/reading wiki.conf file");
 
 	if (! s_p_get_string(&key, "AuthKey", tbl))
diff --git a/src/plugins/select/bluegene/bg_read_config.c b/src/plugins/select/bluegene/bg_read_config.c
index 05fad968655..2bdd0774f7c 100644
--- a/src/plugins/select/bluegene/bg_read_config.c
+++ b/src/plugins/select/bluegene/bg_read_config.c
@@ -338,7 +338,7 @@ extern int read_bg_conf(void)
 	/* bg_conf defined in bg_node_alloc.h */
 	tbl = s_p_hashtbl_create(bg_conf_file_options);
 
-	if (s_p_parse_file(tbl, NULL, bg_conf_file) == SLURM_ERROR)
+	if (s_p_parse_file(tbl, NULL, bg_conf_file, false) == SLURM_ERROR)
 		fatal("something wrong with opening/reading bluegene "
 		      "conf file");
 	xfree(bg_conf_file);
diff --git a/src/plugins/switch/federation/federation.c b/src/plugins/switch/federation/federation.c
index c58c6cf8a05..6ac415c749d 100644
--- a/src/plugins/switch/federation/federation.c
+++ b/src/plugins/switch/federation/federation.c
@@ -517,7 +517,7 @@ static int _parse_fed_file(hostlist_t *adapter_list)
 		fed_conf = _get_fed_conf();
 
 	tbl = s_p_hashtbl_create(options);
-	if(s_p_parse_file(tbl, NULL, fed_conf) == SLURM_ERROR)
+	if(s_p_parse_file(tbl, NULL, fed_conf, false) == SLURM_ERROR)
 		fatal("something wrong with opening/reading federation "
 		      "conf file");
 
diff --git a/src/plugins/topology/tree/topology_tree.c b/src/plugins/topology/tree/topology_tree.c
index 12939a16bce..307d3f7645d 100644
--- a/src/plugins/topology/tree/topology_tree.c
+++ b/src/plugins/topology/tree/topology_tree.c
@@ -456,7 +456,8 @@ extern int  _read_topo_file(slurm_conf_switches_t **ptr_array[])
 		topo_conf = _get_topo_conf();
 
 	conf_hashtbl = s_p_hashtbl_create(switch_options);
-	if (s_p_parse_file(conf_hashtbl, NULL, topo_conf) == SLURM_ERROR) {
+	if (s_p_parse_file(conf_hashtbl, NULL, topo_conf, false) ==
+	    SLURM_ERROR) {
 		fatal("something wrong with opening/reading %s: %m",
 		      topo_conf);
 	}
diff --git a/src/slurmdbd/read_config.c b/src/slurmdbd/read_config.c
index f70b8b1f91d..e6a88c47d66 100644
--- a/src/slurmdbd/read_config.c
+++ b/src/slurmdbd/read_config.c
@@ -188,7 +188,8 @@ extern int read_slurmdbd_conf(void)
 		debug("Reading slurmdbd.conf file %s", conf_path);
 
 		tbl = s_p_hashtbl_create(options);
-		if (s_p_parse_file(tbl, NULL, conf_path) == SLURM_ERROR) {
+		if (s_p_parse_file(tbl, NULL, conf_path, false)
+		    == SLURM_ERROR) {
 			fatal("Could not open/read/parse slurmdbd.conf file %s",
 			      conf_path);
 		}
diff --git a/src/smap/configure_functions.c b/src/smap/configure_functions.c
index e2358cb8575..aa20443f9cf 100644
--- a/src/smap/configure_functions.c
+++ b/src/smap/configure_functions.c
@@ -1176,7 +1176,7 @@ static int _load_configuration(char *com, List allocated_blocks)
 
 /* NOTE: bg_conf_file_options identifies options supported by bluegene.conf */
 	tbl = s_p_hashtbl_create(bg_conf_file_options);
-	if (s_p_parse_file(tbl, NULL, filename) == SLURM_ERROR) {
+	if (s_p_parse_file(tbl, NULL, filename, false) == SLURM_ERROR) {
 		memset(error_string,0,255);
 		sprintf(error_string, "ERROR: couldn't open/read %s",
 			filename);
diff --git a/src/sview/defaults.c b/src/sview/defaults.c
index c06e7a1f581..7b32e1217a5 100644
--- a/src/sview/defaults.c
+++ b/src/sview/defaults.c
@@ -597,7 +597,7 @@ extern int load_defaults(void)
 
 	hashtbl = s_p_hashtbl_create(sview_conf_options);
 
-	if (s_p_parse_file(hashtbl, &hash_val, pathname) == SLURM_ERROR)
+	if (s_p_parse_file(hashtbl, &hash_val, pathname, true) == SLURM_ERROR)
 		error("something wrong with opening/reading conf file");
 
 	s_p_get_boolean(&default_sview_config.admin_mode, "AdminMode", hashtbl);
diff --git a/src/sview/sview.c b/src/sview/sview.c
index fb19d2b56d3..cfbf353c6d4 100644
--- a/src/sview/sview.c
+++ b/src/sview/sview.c
@@ -519,6 +519,30 @@ static void _get_current_debug(GtkRadioAction *action)
 					     debug_level);
 }
 
+static void _get_current_debug_flags(GtkToggleAction *action)
+{
+	static uint32_t debug_flags = 0;
+	static slurm_ctl_conf_info_msg_t  *slurm_ctl_conf_ptr = NULL;
+	int err_code = get_new_info_config(&slurm_ctl_conf_ptr);
+
+	if (err_code != SLURM_ERROR)
+		debug_flags = slurm_ctl_conf_ptr->debug_flags;
+#if 0
+	/* Logic of this sorf should work, but I am not sure how to get each
+	 * GtkToggleButton from the GtkToggleAction argument above */
+	static GtkAction *debug_action = NULL;
+	gboolean flag_state;
+
+	debug_action = gtk_action_group_get_action(menu_action_group, "flags_backfill");
+	flag_state = debug_flags & DEBUG_FLAG_BACKFILL;
+	gtk_toggle_button_set_active(GtkToggleButton, flag_state);
+	/*
+	for (each button) {
+		gtk_toggle_button_set_active(GtkToggleButton, gboolean);
+	} */
+#endif
+}
+	
 static void _set_debug(GtkRadioAction *action,
 		       GtkRadioAction *extra,
 		       GtkNotebook *notebook)
@@ -953,7 +977,7 @@ static GtkWidget *_get_menubar_menu(GtkWidget *window, GtkWidget *notebook)
 		{"debugflags", GTK_STOCK_DIALOG_WARNING,
 		 "Slurmctld DebugFlags",
 		 "", "Set slurmctld DebugFlags",
-		 G_CALLBACK(_get_current_debug)},
+		 G_CALLBACK(_get_current_debug_flags)},
 		{"debuglevel", GTK_STOCK_DIALOG_WARNING,
 		 "Slurmctld Debug Level",
 		 "", "Set slurmctld debug level",
-- 
GitLab