master - fenced: add skip_undefined option

David Teigland teigland@fedoraproject.org
Thu Aug 21 19:20:00 GMT 2008


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=ae10fb681b0ac8449061bb57bd100b5f2a42994e
Commit:        ae10fb681b0ac8449061bb57bd100b5f2a42994e
Parent:        27dd7c7b36949a06e5130f62c8ad0eb4dac19bb8
Author:        David Teigland <teigland@redhat.com>
AuthorDate:    Thu Aug 21 13:28:30 2008 -0500
Committer:     David Teigland <teigland@redhat.com>
CommitterDate: Thu Aug 21 13:28:30 2008 -0500

fenced: add skip_undefined option

bz 459127

New fenced config option <fence_daemon skip_undefined="1"/>
would cause fenced to not do startup fencing of nodes with zero
defined fence methods.

The primary use for this option would be asymmetric cluster configs
(http://sources.redhat.com/cluster/wiki/asymmetric_cluster_config)
where client/small/spectator nodes do not join the fence domain
and have no fencing configured.  The problem we have is that even with
no fencing configured, and not joining the fence domain, other
nodes may attempt (and fail) to fence these client nodes during
startup fencing.

Signed-off-by: David Teigland <teigland@redhat.com>
---
 fence/fenced/config.c |   47 +++++++++++++++++++++++++++++++++++++++++++++--
 fence/fenced/config.h |    3 +++
 fence/fenced/main.c   |    8 +++++++-
 3 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/fence/fenced/config.c b/fence/fenced/config.c
index 791150c..74c6bde 100644
--- a/fence/fenced/config.c
+++ b/fence/fenced/config.c
@@ -9,6 +9,7 @@ static int ccs_handle;
 int optd_groupd_compat;
 int optd_debug_logsys;
 int optd_clean_start;
+int optd_skip_undefined;
 int optd_post_join_delay;
 int optd_post_fail_delay;
 int optd_override_time;
@@ -19,6 +20,7 @@ int optd_override_path;
 int cfgd_groupd_compat   = DEFAULT_GROUPD_COMPAT;
 int cfgd_debug_logsys    = DEFAULT_DEBUG_LOGSYS;
 int cfgd_clean_start     = DEFAULT_CLEAN_START;
+int cfgd_skip_undefined  = DEFAULT_SKIP_UNDEFINED;
 int cfgd_post_join_delay = DEFAULT_POST_JOIN_DELAY;
 int cfgd_post_fail_delay = DEFAULT_POST_FAIL_DELAY;
 int cfgd_override_time   = DEFAULT_OVERRIDE_TIME;
@@ -108,12 +110,31 @@ void read_ccs_int(char *path, int *config_val)
 #define POST_FAIL_DELAY_PATH "/cluster/fence_daemon/@post_fail_delay"
 #define OVERRIDE_PATH_PATH "/cluster/fence_daemon/@override_path"
 #define OVERRIDE_TIME_PATH "/cluster/fence_daemon/@override_time"
+#define METHOD_NAME_PATH "/cluster/clusternodes/clusternode[@name=\"%s\"]/fence/method[%d]/@name"
+
+static int count_methods(char *victim)
+{
+	char path[PATH_MAX], *name;
+	int error, i;
+
+	for (i = 0; i < 2; i++) {
+		memset(path, 0, sizeof(path));
+		sprintf(path, METHOD_NAME_PATH, victim, i+1);
+
+		error = ccs_get(ccs_handle, path, &name);
+		if (error)
+			break;
+		free(name);
+	}
+	return i;
+}
 
 int read_ccs(struct fd *fd)
 {
 	char path[PATH_MAX];
-	char *str;
+	char *str, *name;
 	int error, i = 0, count = 0;
+	int num_methods;
 
 	/* Our own nodename must be in cluster.conf before we're allowed to
 	   join the fence domain and then mount gfs; other nodes need this to
@@ -169,8 +190,30 @@ int read_ccs(struct fd *fd)
 		if (error || !str)
 			break;
 
-		add_complete_node(fd, atoi(str));
+		name = NULL;
+		memset(path, 0, sizeof(path));
+		sprintf(path, "/cluster/clusternodes/clusternode[%d]/@name", i);
+
+		error = ccs_get(ccs_handle, path, &name);
+		if (error || !name) {
+			log_error("node name query failed for num %d nodeid %s",
+				  i, str);
+			break;
+		}
+
+		num_methods = count_methods(name);
+
+		/* the libcpg code only uses the fd->complete list for
+		   determining initial victims; the libgroup code uses
+		   fd->complete more extensively */
+
+		if (cfgd_skip_undefined && !num_methods)
+			log_debug("skip %s with zero methods", name);
+		else
+			add_complete_node(fd, atoi(str));
+
 		free(str);
+		free(name);
 		count++;
 	}
 
diff --git a/fence/fenced/config.h b/fence/fenced/config.h
index eea8cb6..c39c7af 100644
--- a/fence/fenced/config.h
+++ b/fence/fenced/config.h
@@ -4,6 +4,7 @@
 #define DEFAULT_GROUPD_COMPAT 2
 #define DEFAULT_DEBUG_LOGSYS 0
 #define DEFAULT_CLEAN_START 0
+#define DEFAULT_SKIP_UNDEFINED 0
 #define DEFAULT_POST_JOIN_DELAY 6
 #define DEFAULT_POST_FAIL_DELAY 0
 #define DEFAULT_OVERRIDE_TIME 3
@@ -12,6 +13,7 @@
 extern int optd_groupd_compat;
 extern int optd_debug_logsys;
 extern int optd_clean_start;
+extern int optd_skip_undefined;
 extern int optd_post_join_delay;
 extern int optd_post_fail_delay;
 extern int optd_override_time;
@@ -20,6 +22,7 @@ extern int optd_override_path;
 extern int cfgd_groupd_compat;
 extern int cfgd_debug_logsys;
 extern int cfgd_clean_start;
+extern int cfgd_skip_undefined;
 extern int cfgd_post_join_delay;
 extern int cfgd_post_fail_delay;
 extern int cfgd_override_time;
diff --git a/fence/fenced/main.c b/fence/fenced/main.c
index bc6ee11..ae5f662 100644
--- a/fence/fenced/main.c
+++ b/fence/fenced/main.c
@@ -758,6 +758,7 @@ static void print_usage(void)
 	printf("               2: use groupd to detect old, or mode 1, nodes that\n"
 	       "               require compat, use libcpg if none found\n");
 	printf("  -c           All nodes are in a clean state to start\n");
+	printf("  -s           Skip startup fencing of nodes with no defined fence methods\n");
 	printf("  -j <secs>    Post-join fencing delay (default %d)\n", DEFAULT_POST_JOIN_DELAY);
 	printf("  -f <secs>    Post-fail fencing delay (default %d)\n", DEFAULT_POST_FAIL_DELAY);
 	printf("  -R <secs>    Override time (default %d)\n", DEFAULT_OVERRIDE_TIME);
@@ -771,7 +772,7 @@ static void print_usage(void)
 	printf("\n");
 }
 
-#define OPTION_STRING	"L:g:cj:f:Dn:O:T:hVS"
+#define OPTION_STRING	"L:g:cj:f:Dn:O:hVSs"
 
 static void read_arguments(int argc, char **argv)
 {
@@ -802,6 +803,11 @@ static void read_arguments(int argc, char **argv)
 			cfgd_clean_start = 1;
 			break;
 
+		case 's':
+			optd_skip_undefined = 1;
+			cfgd_skip_undefined = 1;
+			break;
+
 		case 'j':
 			optd_post_join_delay = 1;
 			cfgd_post_join_delay = atoi(optarg);



More information about the Cluster-cvs mailing list