From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2979 invoked by alias); 28 Aug 2008 18:14:08 -0000 Received: (qmail 2973 invoked by alias); 28 Aug 2008 18:14:08 -0000 X-Spam-Status: No, hits=0.4 required=5.0 tests=AWL,BAYES_50,J_CHICKENPOX_43,J_CHICKENPOX_82,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: RHEL5 - rgmanager: Implement wait-for-fence behavior To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/RHEL5 X-Git-Reftype: branch X-Git-Oldrev: 288ee1d7d73d6d4b08dc2ae0d0fb66f70d23f2fd X-Git-Newrev: b856823dbc6310e3c4742bf986bf2fa991cdc334 From: Lon Hohberger Message-Id: <20080828181250.66440120379@lists.fedorahosted.org> Date: Thu, 28 Aug 2008 19:36: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/msg00352.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=b856823dbc6310e3c4742bf986bf2fa991cdc334 Commit: b856823dbc6310e3c4742bf986bf2fa991cdc334 Parent: 288ee1d7d73d6d4b08dc2ae0d0fb66f70d23f2fd Author: Lon Hohberger AuthorDate: Thu Aug 28 14:12:26 2008 -0400 Committer: Lon Hohberger CommitterDate: Thu Aug 28 14:12:38 2008 -0400 rgmanager: Implement wait-for-fence behavior Changes to group/lib/Makefile are needed to make libgroup.so a shared object so as to not cause rgmanager to depend on a particular release of cman. Changes to group/lib/Makefile mirror what cman/lib/Makefile does to create shared libraries This change implements a wait to ensure fencing has completed prior to services in rgmanager being allowed to start. This is rhbz #459754 --- group/lib/Makefile | 17 ++++++++++++++--- rgmanager/src/daemons/Makefile | 6 +++--- rgmanager/src/daemons/main.c | 25 ++++++++++++++++++++++++- rgmanager/src/daemons/rg_event.c | 21 +++++++++++++++++++++ 4 files changed, 62 insertions(+), 7 deletions(-) diff --git a/group/lib/Makefile b/group/lib/Makefile index fb86073..733109a 100644 --- a/group/lib/Makefile +++ b/group/lib/Makefile @@ -13,25 +13,36 @@ SOURCE=libgroup.c LIBNAME=libgroup +SHAREDLIB=$(LIBNAME).so.${RELEASE_MAJOR}.${RELEASE_MINOR} STATICLIB=$(LIBNAME).a top_srcdir=.. UNINSTALL=${top_srcdir}/scripts/uninstall.pl -# include ${top_srcdir}/make/defines.mk +include ${top_srcdir}/make/defines.mk CFLAGS += -g -O -I. -fPIC -I../daemon -all: $(STATICLIB) +all: $(STATICLIB) $(SHAREDLIB) $(LIBNAME).a: libgroup.o ${AR} r libgroup.a libgroup.o -# ${RANLIB} libgroup.a + ${RANLIB} libgroup.a + +$(LIBNAME).so.${RELEASE_MAJOR}.${RELEASE_MINOR}: libgroup.o + $(CC) -shared -o $@ -Wl,-soname=$(LIBNAME).so.$(RELEASE_MAJOR) $^ libgroup.o: libgroup.c $(CC) $(CFLAGS) -c -o $@ $< -I../daemon install: all + install -d ${incdir} + install libgroup.h ${incdir} + install -d ${libdir} + install $(LIBNAME).a ${libdir} + install $(LIBNAME).so.$(RELEASE_MAJOR).$(RELEASE_MINOR) ${libdir} + ln -sf $(LIBNAME).so.$(RELEASE_MAJOR).$(RELEASE_MINOR) ${libdir}/$(LIBNAME).so + ln -sf $(LIBNAME).so.$(RELEASE_MAJOR).$(RELEASE_MINOR) ${libdir}/$(LIBNAME).so.$(RELEASE_MAJOR) uninstall: diff --git a/rgmanager/src/daemons/Makefile b/rgmanager/src/daemons/Makefile index 5812fe6..b743de7 100644 --- a/rgmanager/src/daemons/Makefile +++ b/rgmanager/src/daemons/Makefile @@ -14,12 +14,12 @@ top_srcdir=../.. UNINSTALL=${top_srcdir}/scripts/uninstall.pl include ${top_srcdir}/make/defines.mk -INCLUDE += -I $(top_srcdir)/include -I $(top_srcdir)/../cman/lib -I $(top_srcdir)/../ccs/lib -I $(top_srcdir)/../dlm/lib +INCLUDE += -I $(top_srcdir)/include -I $(top_srcdir)/../cman/lib -I $(top_srcdir)/../ccs/lib -I $(top_srcdir)/../dlm/lib -I $(top_srcdir)/../group/lib INCLUDE += -I${incdir} -I/usr/include/libxml2 -I/usr/include/slang CFLAGS+= -g -Wstrict-prototypes -Wshadow -fPIC -D_GNU_SOURCE -DWRAP_THREADS -Wall -Wextra -LDFLAGS+= -L ../clulib -L../../../cman/lib -L../../../ccs/lib -L../../../dlm/lib -L${libdir} -lclulib -lxml2 -lpthread -ldl -Wl,-wrap,pthread_create,-wrap,pthread_exit -rdynamic +LDFLAGS+= -L ../clulib -L../../../cman/lib -L../../../ccs/lib -L../../../dlm/lib -L../../../group/lib -L${libdir} -lclulib -lxml2 -lpthread -ldl -Wl,-wrap,pthread_create,-wrap,pthread_exit TARGETS=clurgmgrd clurmtabd rg_test all: ${TARGETS} @@ -41,7 +41,7 @@ clurgmgrd: rg_thread.o rg_locks.o main.o groups.o \ rg_event.o watchdog.o rg_state.o event_config.o \ slang_event.o service_op.o restart_counter.o \ ../clulib/libclulib.a - $(CC) -o $@ $^ $(INCLUDE) $(CFLAGS) $(LDFLAGS) -lccs -lcman -lpthread -ldlm -lslang + $(CC) -o $@ $^ $(INCLUDE) $(CFLAGS) $(LDFLAGS) -lccs -lcman -lgroup -lpthread -ldlm -lslang rg_script_test: slang_event.o $(CC) -o rg_script_test slang_event.o $(INCLUDE) $(CFLAGS) -lslang $(LDFLAGS) diff --git a/rgmanager/src/daemons/main.c b/rgmanager/src/daemons/main.c index 8401bca..b722ab2 100644 --- a/rgmanager/src/daemons/main.c +++ b/rgmanager/src/daemons/main.c @@ -60,6 +60,9 @@ int svc_exists(char *); int watchdog_init(void); int32_t master_event_callback(char *key, uint64_t viewno, void *data, uint32_t datalen); +int node_has_fencing(int nodeid); +int fence_domain_joined(void); + int shutdown_pending = 0, running = 1, need_reconfigure = 0; char debug = 0; /* XXX* */ static int signalled = 0; @@ -909,7 +912,25 @@ clu_initialize(cman_handle_t *ch) while (cman_is_quorate(*ch) == 0) { sleep(1); } - clulog(LOG_NOTICE, "Quorum formed, starting\n"); + clulog(LOG_NOTICE, "Quorum formed\n"); + } + +} + + +void +wait_for_fencing(void) +{ + if (node_has_fencing(my_id()) && !fence_domain_joined()) { + clulog(LOG_INFO, "Waiting for fence domain join operation " + "to complete\n"); + + while (fence_domain_joined() == 0) + sleep(1); + clulog(LOG_INFO, "Fence domain joined\n"); + } else { + clulog(LOG_DEBUG, "Fence domain already joined " + "or no fencing configured\n"); } } @@ -1018,6 +1039,8 @@ main(int argc, char **argv) clulog(LOG_INFO, "I am node #%d\n", my_id()); + wait_for_fencing(); + /* We know we're quorate. At this point, we need to read the resource group trees from ccsd. diff --git a/rgmanager/src/daemons/rg_event.c b/rgmanager/src/daemons/rg_event.c index f614668..f8fcc1e 100644 --- a/rgmanager/src/daemons/rg_event.c +++ b/rgmanager/src/daemons/rg_event.c @@ -27,6 +27,7 @@ #include #include #include +#include /** @@ -174,6 +175,26 @@ node_has_fencing(int nodeid) } +/* Shameless cut-and-paste from gfs_controld */ +int +fence_domain_joined(void) +{ + group_data_t data; + int rv; + + memset(&data, 0, sizeof(data)); + + rv = group_get_group(0, "default", &data); + + if (rv || strcmp(data.client_name, "fence")) + return 0; + + if (data.member == 1) + return 1; + return 0; +} + + /** Quick query to cman to see if a node has been fenced. */