From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21261 invoked by alias); 30 Jul 2008 20:33:47 -0000 Received: (qmail 21226 invoked by alias); 30 Jul 2008 20:33:47 -0000 X-Spam-Status: No, hits=-0.5 required=5.0 tests=AWL,BAYES_00,KAM_MX,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on bastion.fedora.phx.redhat.com X-Spam-Level: Subject: master - fenced: use group_mode detection To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: f090526867f97d09f3813b7e0e1ca09ed650d71d X-Git-Newrev: 16ea71248f91435c5489f3c1c2d9375a9024c92e From: David Teigland Message-Id: <20080730203257.7FF8C120021@lists.fedorahosted.org> Date: Wed, 30 Jul 2008 20:33:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2008-q3/txt/msg00177.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=16ea71248f91435c5489f3c1c2d9375a9024c92e Commit: 16ea71248f91435c5489f3c1c2d9375a9024c92e Parent: f090526867f97d09f3813b7e0e1ca09ed650d71d Author: David Teigland AuthorDate: Wed Jul 30 14:04:13 2008 -0500 Committer: David Teigland CommitterDate: Wed Jul 30 14:04:13 2008 -0500 fenced: use group_mode detection The new default is to use group mode detection from groupd. This is -g2 (command line) or (cluster.conf). Signed-off-by: David Teigland --- fence/fenced/config.h | 2 +- fence/fenced/fd.h | 1 + fence/fenced/group.c | 28 ++++++++++++++++++++++++++++ fence/fenced/main.c | 19 +++++++++---------- group/daemon/main.c | 20 +++++++++++++------- group/lib/libgroup.c | 1 - 6 files changed, 52 insertions(+), 19 deletions(-) diff --git a/fence/fenced/config.h b/fence/fenced/config.h index 4ee9522..eea8cb6 100644 --- a/fence/fenced/config.h +++ b/fence/fenced/config.h @@ -1,7 +1,7 @@ #ifndef __CONFIG_DOT_H__ #define __CONFIG_DOT_H__ -#define DEFAULT_GROUPD_COMPAT 1 +#define DEFAULT_GROUPD_COMPAT 2 #define DEFAULT_DEBUG_LOGSYS 0 #define DEFAULT_CLEAN_START 0 #define DEFAULT_POST_JOIN_DELAY 6 diff --git a/fence/fenced/fd.h b/fence/fenced/fd.h index c6c6118..2f54143 100644 --- a/fence/fenced/fd.h +++ b/fence/fenced/fd.h @@ -227,6 +227,7 @@ int set_node_info_group(struct fd *fd, int nodeid, struct fenced_node *node); int set_domain_info_group(struct fd *fd, struct fenced_domain *domain); int set_domain_nodes_group(struct fd *fd, int option, int *node_count, struct fenced_node **nodes); +void set_group_mode(void); /* main.c */ diff --git a/fence/fenced/group.c b/fence/fenced/group.c index 981a94b..3217518 100644 --- a/fence/fenced/group.c +++ b/fence/fenced/group.c @@ -441,3 +441,31 @@ int set_domain_nodes_group(struct fd *fd, int option, int *node_count, return 0; } +void set_group_mode(void) +{ + int i = 0, rv, version; + + while (1) { + rv = group_get_version(&version); + if (rv) { + log_error("group_get_version error %d", rv); + break; + } else if (version == GROUP_LIBGROUP) { + group_mode = GROUP_LIBGROUP; + break; + } else if (version == GROUP_LIBCPG) { + group_mode = GROUP_LIBCPG; + break; + } else if (version != -EAGAIN) { + log_error("group_get_version result %d", version); + break; + } + + if (i++ > 10) { + log_error("no version from groupd"); + break; + } + sleep(1); + } +} + diff --git a/fence/fenced/main.c b/fence/fenced/main.c index d3737eb..3c88197 100644 --- a/fence/fenced/main.c +++ b/fence/fenced/main.c @@ -635,12 +635,10 @@ static void loop(void) client_add(rv, process_groupd, cluster_dead); group_mode = GROUP_LIBGROUP; - - if (cfgd_groupd_compat == 2) { - /* set_group_mode(); */ - group_mode = GROUP_LIBGROUP; - } + if (cfgd_groupd_compat == 2) + set_group_mode(); } + log_debug("group_mode %d compat %d", group_mode, cfgd_groupd_compat); if (group_mode == GROUP_LIBCPG) { /* @@ -746,11 +744,12 @@ static void print_usage(void) printf("\n"); printf(" -D Enable debugging code and don't fork\n"); printf(" -L Enable (1) or disable (0) debugging to logsys (default %d)\n", DEFAULT_DEBUG_LOGSYS); - printf(" -g groupd compatibility, 0 off, 1 on\n"); - printf(" on: use libgroup, compat with cluster2/stable2/rhel5\n"); - printf(" off: use libcpg, no backward compatability\n"); - printf(" Default is %d\n", DEFAULT_GROUPD_COMPAT); - printf(" -c All nodes are in a clean state to start\n"); + printf(" -g groupd compatibility mode, 0 off, 1 on, 2 detect (default %d)\n", DEFAULT_GROUPD_COMPAT); + printf(" 0: use libcpg, no backward compat, best performance\n"); + printf(" 1: use libgroup for compat with cluster2/rhel5\n"); + 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(" -j Post-join fencing delay (default %d)\n", DEFAULT_POST_JOIN_DELAY); printf(" -f Post-fail fencing delay (default %d)\n", DEFAULT_POST_FAIL_DELAY); printf(" -R Override time (default %d)\n", DEFAULT_OVERRIDE_TIME); diff --git a/group/daemon/main.c b/group/daemon/main.c index 8059908..9d00c24 100644 --- a/group/daemon/main.c +++ b/group/daemon/main.c @@ -627,7 +627,10 @@ static int do_get_version(int ci) int mode; int rv; - mode = group_mode; + if (group_mode == GROUP_PENDING) + mode = -EAGAIN; + else + mode = group_mode; rv = do_write(client[ci].fd, &mode, sizeof(mode)); if (rv < 0) @@ -974,13 +977,16 @@ static void print_usage(void) printf(" -L Enable (1) or disable (0) debugging to logsys (default %d)\n", DEFAULT_DEBUG_LOGSYS); printf(" -g group compatibility mode, 0 off, 1 on, 2 detect\n"); printf(" 0: use libcpg, no backward compat, best performance\n"); - printf(" 1: use libgroup for compat with cluster2/stable2/rhel5\n"); - printf(" 2: detect old, or mode 0, nodes that require compat, use libcpg if none found\n"); + printf(" 1: use libgroup for compat with cluster2/rhel5\n"); + printf(" 2: detect old, or mode 1, nodes that require compat,\n" + " use libcpg if none found\n"); printf(" Default is %d\n", DEFAULT_GROUPD_COMPAT); - printf(" -w seconds to wait for a node's version message before assuming an old version requiring compat mode\n"); - printf(" Default is %d", DEFAULT_GROUPD_WAIT); - printf(" -d seconds to delay the mode selection to give time for an old version to join and force compat mode\n"); - printf(" Default is %d", DEFAULT_GROUPD_MODE_DELAY); + printf(" -w seconds to wait for a node's version message before\n" + " assuming an old version requiring compat mode\n"); + printf(" Default is %d\n", DEFAULT_GROUPD_WAIT); + printf(" -d seconds to delay the mode selection to give time\n" + " for an old version to join and force compat mode\n"); + printf(" Default is %d\n", DEFAULT_GROUPD_MODE_DELAY); printf(" -h Print this help, then exit\n"); printf(" -V Print program version information, then exit\n"); } diff --git a/group/lib/libgroup.c b/group/lib/libgroup.c index 82fe3fb..c86ac25 100644 --- a/group/lib/libgroup.c +++ b/group/lib/libgroup.c @@ -500,7 +500,6 @@ int group_get_group(int level, const char *name, group_data_t *data) int group_get_version(int *version) { char buf[GROUPD_MSGLEN]; - char data_buf[sizeof(int)]; int fd, rv; fd = connect_groupd();