STABLE2 - fenced: add skip_undefined option

David Teigland teigland@fedoraproject.org
Thu Aug 21 18:39:00 GMT 2008


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=c9ce9e3c7e6b5eac73ecca416a5fe98f72bbd7aa
Commit:        c9ce9e3c7e6b5eac73ecca416a5fe98f72bbd7aa
Parent:        2c84dad158099d33d5f68f0416fa9389ddd8a1b6
Author:        David Teigland <teigland@redhat.com>
AuthorDate:    Thu Aug 14 11:35:51 2008 -0500
Committer:     David Teigland <teigland@redhat.com>
CommitterDate: Wed Aug 20 15:21:19 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/agent.c |    2 +-
 fence/fenced/fd.h    |    4 ++++
 fence/fenced/main.c  |   29 ++++++++++++++++++++++++++++-
 3 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/fence/fenced/agent.c b/fence/fenced/agent.c
index 033f447..a41dd03 100644
--- a/fence/fenced/agent.c
+++ b/fence/fenced/agent.c
@@ -206,7 +206,7 @@ static int get_device(int cd, char *victim, char *method, int d, char **device)
 	return error;
 }
 
-static int count_methods(int cd, char *victim)
+int count_methods(int cd, char *victim)
 {
 	char path[256], *name;
 	int error, i;
diff --git a/fence/fenced/fd.h b/fence/fenced/fd.h
index f45be11..90bfdcb 100644
--- a/fence/fenced/fd.h
+++ b/fence/fenced/fd.h
@@ -40,6 +40,7 @@
 #define DEFAULT_POST_JOIN_DELAY	6
 #define DEFAULT_POST_FAIL_DELAY	0
 #define DEFAULT_CLEAN_START	0
+#define DEFAULT_SKIP_UNDEFINED	0
 #define DEFAULT_OVERRIDE_PATH	"/var/run/cluster/fenced_override"
 #define FENCED_SOCK_PATH	"fenced_socket"
 
@@ -123,9 +124,11 @@ struct commandline
 	int pad;
 	char *override_path;
 	int8_t clean_start;
+	int8_t skip_undefined;
 	int8_t post_join_delay_opt;
 	int8_t post_fail_delay_opt;
 	int8_t clean_start_opt;
+	int8_t skip_undefined_opt;
 	int8_t override_path_opt;
 	int8_t override_time_opt;
 };
@@ -167,6 +170,7 @@ void do_recovery_done(fd_t *fd);
 
 /* agent.c */
 int dispatch_fence_agent(char *victim, int force);
+int count_methods(int cd, char *victim);
 
 /* group.c */
 int setup_groupd(void);
diff --git a/fence/fenced/main.c b/fence/fenced/main.c
index 9e2d901..50b9aa2 100644
--- a/fence/fenced/main.c
+++ b/fence/fenced/main.c
@@ -2,7 +2,7 @@
 #include "ccs.h"
 #include "copyright.cf"
 
-#define OPTION_STRING			("cj:f:Dn:O:T:hVS")
+#define OPTION_STRING			("cj:f:Dn:O:hVSws")
 #define LOCKFILE_NAME			"/var/run/fenced.pid"
 
 struct client {
@@ -104,6 +104,20 @@ static int setup_ccs(fd_t *fd)
 			free(str);
 	}
 
+	if (comline.skip_undefined_opt == FALSE) {
+		str = NULL;
+		memset(path, 0, 256);
+		sprintf(path, "/cluster/fence_daemon/@skip_undefined");
+
+		error = ccs_get(cd, path, &str);
+		if (!error)
+			comline.skip_undefined = atoi(str);
+		else
+			comline.skip_undefined = DEFAULT_SKIP_UNDEFINED;
+		if (str)
+			free(str);
+	}
+
 	if (comline.post_join_delay_opt == FALSE) {
 		str = NULL;
 		memset(path, 0, 256);
@@ -180,6 +194,13 @@ static int setup_ccs(fd_t *fd)
 		if (error || !name)
 			break;
 
+		num_methods = count_methods(cd, name);
+
+		if (comline.skip_undefined && !num_methods) {
+			log_debug("skip %s with zero methods", name);
+			continue;
+		}
+
 		add_complete_node(fd, 0, name);
 		free(name);
 		count++;
@@ -519,6 +540,7 @@ static void print_usage(void)
 	printf("Options:\n");
 	printf("\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",
@@ -590,6 +612,11 @@ static void decode_arguments(int argc, char **argv, commandline_t *comline)
 			comline->clean_start_opt = TRUE;
 			break;
 
+		case 's':
+			comline->skip_undefined = 1;
+			comline->skip_undefined_opt = TRUE;
+			break;
+
 		case 'j':
 			comline->post_join_delay = atoi(optarg);
 			comline->post_join_delay_opt = TRUE;



More information about the Cluster-cvs mailing list