Просмотр исходного кода

Reapply config defaults corosync.conf reload

There were several places where defaults were not restored
if the keys were removed from corosync.conf and the file reloaded.

This patch adds those back so that reloading corosync.conf
has the expected effect when keys are deleted.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
Christine Caulfield 9 лет назад
Родитель
Сommit
125848d80a
3 измененных файлов с 57 добавлено и 4 удалено
  1. 1 0
      exec/cfg.c
  2. 48 4
      exec/logconfig.c
  3. 8 0
      exec/votequorum.c

+ 1 - 0
exec/cfg.c

@@ -703,6 +703,7 @@ static void message_handler_req_exec_cfg_reload_config (
 	remove_deleted_entries(temp_map, "totem.");
 	remove_deleted_entries(temp_map, "nodelist.");
 	remove_deleted_entries(temp_map, "quorum.");
+	remove_deleted_entries(temp_map, "uidgid.");
 
 	/* Remove entries that cannot be changed */
 	remove_ro_entries(temp_map);

+ 48 - 4
exec/logconfig.c

@@ -235,6 +235,7 @@ static int corosync_main_config_log_destination_set (
 	const char **error_string,
 	unsigned int mode_mask,
 	char deprecated,
+	char default_value,
 	const char *replacement)
 {
 	static char formatted_error_reason[128];
@@ -271,6 +272,20 @@ static int corosync_main_config_log_destination_set (
 			goto parse_error;
 		}
 	}
+	else {
+		/* Set to default */
+		mode = logsys_config_mode_get (subsys);
+		if (default_value) {
+			mode |= mode_mask;
+		}
+		else {
+			mode &= ~mode_mask;
+		}
+		if (logsys_config_mode_set(subsys, mode) < 0) {
+			sprintf (formatted_error_reason, "unable to unset mode %s", key);
+			goto parse_error;
+		}
+	}
 
 	free(value);
 	return (0);
@@ -314,11 +329,11 @@ static int corosync_main_config_set (
 	}
 
 	if (corosync_main_config_log_destination_set (path, "to_stderr", subsys, &error_reason,
-	    LOGSYS_MODE_OUTPUT_STDERR, 0, NULL) != 0)
+	    LOGSYS_MODE_OUTPUT_STDERR, 0, 1, NULL) != 0)
 		goto parse_error;
 
 	if (corosync_main_config_log_destination_set (path, "to_syslog", subsys, &error_reason,
-	    LOGSYS_MODE_OUTPUT_SYSLOG, 0, NULL) != 0)
+	    LOGSYS_MODE_OUTPUT_SYSLOG, 0, 1, NULL) != 0)
 		goto parse_error;
 
 	snprintf(key_name, MAP_KEYNAME_MAXLEN, "%s.%s", path, "syslog_facility");
@@ -338,6 +353,14 @@ static int corosync_main_config_set (
 
 		free(value);
 	}
+	else {
+		/* Set default here in case of a reload */
+		if (logsys_config_syslog_facility_set(subsys,
+						      qb_log_facility2int("daemon")) < 0) {
+			error_reason = "unable to set syslog facility";
+			goto parse_error;
+		}
+	}
 
 	snprintf(key_name, MAP_KEYNAME_MAXLEN, "%s.%s", path, "syslog_level");
 	if (map_get_string(key_name, &value) == CS_OK) {
@@ -377,6 +400,13 @@ static int corosync_main_config_set (
 			goto parse_error;
 		}
 	}
+	else {
+		if (logsys_config_syslog_priority_set(subsys,
+						      logsys_priority_id_get("info")) < 0) {
+			error_reason = "unable to set syslog level";
+			goto parse_error;
+		}
+	}
 
 #ifdef LOGCONFIG_USE_ICMAP
 	snprintf(key_name, MAP_KEYNAME_MAXLEN, "%s.%s", path, "logfile");
@@ -395,11 +425,11 @@ static int corosync_main_config_set (
 #endif
 
 	if (corosync_main_config_log_destination_set (path, "to_file", subsys, &error_reason,
-	    LOGSYS_MODE_OUTPUT_FILE, 1, "to_logfile") != 0)
+	   LOGSYS_MODE_OUTPUT_FILE, 1, 0, "to_logfile") != 0)
 		goto parse_error;
 
 	if (corosync_main_config_log_destination_set (path, "to_logfile", subsys, &error_reason,
-	    LOGSYS_MODE_OUTPUT_FILE, 0, NULL) != 0)
+	   LOGSYS_MODE_OUTPUT_FILE, 0, 0, NULL) != 0)
 		goto parse_error;
 
 	snprintf(key_name, MAP_KEYNAME_MAXLEN, "%s.%s", path, "logfile_priority");
@@ -418,6 +448,13 @@ static int corosync_main_config_set (
 			goto parse_error;
 		}
 	}
+	else {
+		if (logsys_config_logfile_priority_set(subsys,
+						      logsys_priority_id_get("info")) < 0) {
+			error_reason = "unable to set syslog level";
+			goto parse_error;
+		}
+	}
 
 	snprintf(key_name, MAP_KEYNAME_MAXLEN, "%s.%s", path, "debug");
 	if (map_get_string(key_name, &value) == CS_OK) {
@@ -448,6 +485,13 @@ static int corosync_main_config_set (
 		}
 		free(value);
 	}
+	else {
+		if (logsys_config_debug_set (subsys, LOGSYS_DEBUG_OFF) < 0) {
+			error_reason = "unable to set debug off";
+			free(value);
+			goto parse_error;
+		}
+	}
 
 	return (0);
 

+ 8 - 0
exec/votequorum.c

@@ -1237,6 +1237,14 @@ static char *votequorum_readconfig(int runtime)
 
 	log_printf(LOGSYS_LEVEL_DEBUG, "Reading configuration (runtime: %d)", runtime);
 
+	/*
+	 * Set the few things we re-read at runtime back to their defaults
+	 */
+	if (runtime) {
+		two_node = 0;
+		expected_votes = 0;
+	}
+
 	/*
 	 * gather basic data here
 	 */