public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* RHEL5 - rgmanager: Implement wait-for-fence behavior
@ 2008-08-28 19:36 Lon Hohberger
0 siblings, 0 replies; only message in thread
From: Lon Hohberger @ 2008-08-28 19:36 UTC (permalink / raw)
To: cluster-cvs-relay
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=b856823dbc6310e3c4742bf986bf2fa991cdc334
Commit: b856823dbc6310e3c4742bf986bf2fa991cdc334
Parent: 288ee1d7d73d6d4b08dc2ae0d0fb66f70d23f2fd
Author: Lon Hohberger <lhh@redhat.com>
AuthorDate: Thu Aug 28 14:12:26 2008 -0400
Committer: Lon Hohberger <lhh@redhat.com>
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 <stdint.h>
#include <vf.h>
#include <members.h>
+#include <libgroup.h>
/**
@@ -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.
*/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-08-28 18:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-28 19:36 RHEL5 - rgmanager: Implement wait-for-fence behavior Lon Hohberger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).