This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RHEL5 - fenced: add skip_undefined option


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=d2184b7d13e079a49a68b5ac93d8fe7ffdce8f42
Commit:        d2184b7d13e079a49a68b5ac93d8fe7ffdce8f42
Parent:        928f894f0156291264b7981140cea10bb0128141
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:11:58 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 66ae77a..e3aab9a 100644
--- a/fence/fenced/agent.c
+++ b/fence/fenced/agent.c
@@ -219,7 +219,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 0b78d19..c4204c8 100644
--- a/fence/fenced/fd.h
+++ b/fence/fenced/fd.h
@@ -53,6 +53,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"
 
@@ -134,9 +135,11 @@ struct commandline
 	int post_fail_delay;
 	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;
 };
 
@@ -177,6 +180,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 c3d1720..65c8a40 100644
--- a/fence/fenced/main.c
+++ b/fence/fenced/main.c
@@ -15,7 +15,7 @@
 #include "ccs.h"
 #include "copyright.cf"
 
-#define OPTION_STRING			("cj:f:Dn:O:hVSw")
+#define OPTION_STRING			("cj:f:Dn:O:hVSws")
 #define LOCKFILE_NAME			"/var/run/fenced.pid"
 
 struct client {
@@ -117,6 +117,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);
@@ -179,6 +193,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++;
@@ -518,6 +539,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",
@@ -587,6 +609,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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]