[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] cluster/rgmanager include/members.h include/re ...



CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	lhh sourceware org	2007-03-20 17:09:57

Modified files:
	rgmanager/include: members.h resgroup.h reslist.h 
	rgmanager/src/clulib: Makefile 
	rgmanager/src/daemons: Makefile depends.c fo_domain.c groups.c 
	                       main.c nodeevent.c rg_state.c 
	rgmanager/src/utils: Makefile clufindhostname.c clusvcadm.c 

Log message:
	Apply build cleanup patch from Fabio M. Di Nitto

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/members.h.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/resgroup.h.diff?cvsroot=cluster&r1=1.18&r2=1.19
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/reslist.h.diff?cvsroot=cluster&r1=1.17&r2=1.18
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/Makefile.diff?cvsroot=cluster&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/Makefile.diff?cvsroot=cluster&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/depends.c.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/fo_domain.c.diff?cvsroot=cluster&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/groups.c.diff?cvsroot=cluster&r1=1.28&r2=1.29
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/main.c.diff?cvsroot=cluster&r1=1.34&r2=1.35
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/nodeevent.c.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/rg_state.c.diff?cvsroot=cluster&r1=1.29&r2=1.30
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/utils/Makefile.diff?cvsroot=cluster&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/utils/clufindhostname.c.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/utils/clusvcadm.c.diff?cvsroot=cluster&r1=1.17&r2=1.18

--- cluster/rgmanager/include/members.h	2006/09/27 16:28:41	1.3
+++ cluster/rgmanager/include/members.h	2007/03/20 17:09:56	1.4
@@ -15,10 +15,12 @@
 cluster_member_list_t * get_member_list(cman_handle_t h);
 void free_member_list(cluster_member_list_t *ml);
 void member_set_state(int nodeid, int state);
+int memb_count(cluster_member_list_t *ml);
 int member_online(int nodeid);
 int memb_online(cluster_member_list_t *ml, int nodeid);
 int memb_online_name(cluster_member_list_t *ml, char *name);
 int memb_name_to_id(cluster_member_list_t *ml, char *name);
+int memb_mark_down(cluster_member_list_t *ml, int nodeid);
 char * memb_id_to_name(cluster_member_list_t *ml, int nodeid);
 cman_node_t * memb_id_to_p(cluster_member_list_t *ml, int nodeid);
 cman_node_t * memb_name_to_p(cluster_member_list_t *ml, char *name);
--- cluster/rgmanager/include/resgroup.h	2007/03/10 00:20:54	1.18
+++ cluster/rgmanager/include/resgroup.h	2007/03/20 17:09:56	1.19
@@ -108,6 +108,9 @@
 const char *rg_state_str(int val);
 const char *agent_op_str(int val);
 
+int eval_groups(int local, uint32_t nodeid, int nodeStatus);
+int group_migrate(char *groupname, int target);
+
 int rg_status(const char *resgroupname);
 int group_op(char *rgname, int op);
 void rg_init(void);
@@ -118,6 +121,7 @@
 int svc_status(char *svcName);
 int svc_disable(char *svcName);
 int svc_fail(char *svcName);
+int svc_migrate(char *svcName, int target);
 int rt_enqueue_request(const char *resgroupname, int request,
 		       msgctx_t *resp_ctx,
        		       int max, uint32_t target, int arg0, int arg1);
--- cluster/rgmanager/include/reslist.h	2007/03/10 00:20:54	1.17
+++ cluster/rgmanager/include/reslist.h	2007/03/20 17:09:56	1.18
@@ -142,7 +142,11 @@
 int res_status(resource_node_t **tree, resource_t *res, void *ret);
 int res_condstart(resource_node_t **tree, resource_t *res, void *ret);
 int res_condstop(resource_node_t **tree, resource_t *res, void *ret);
+int res_exec(resource_node_t *node, const char *op, const char *arg, int depth);
 /*int res_resinfo(resource_node_t **tree, resource_t *res, void *ret);*/
+int expand_time(char *val);
+int store_action(resource_act_t **actsp, char *name, int depth, int timeout, int interval);
+
 
 /*
    Calculate differences
--- cluster/rgmanager/src/clulib/Makefile	2006/07/12 14:38:00	1.10
+++ cluster/rgmanager/src/clulib/Makefile	2007/03/20 17:09:56	1.11
@@ -15,11 +15,10 @@
 
 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
-
-CFLAGS+= -g -I${incdir} -DCMAN_RELEASE_NAME=\"${RELEASE}\"
+INCLUDE += -I${incdir}
 
 CFLAGS+= -g -Wstrict-prototypes -Wshadow -fPIC -D_GNU_SOURCE
-
+CFLAGS+= -DCMAN_RELEASE_NAME=\"${RELEASE}\"
 
 TARGETS=libclulib.a liblalloc.a msgtest 
 
--- cluster/rgmanager/src/daemons/Makefile	2007/02/20 19:56:18	1.16
+++ cluster/rgmanager/src/daemons/Makefile	2007/03/20 17:09:57	1.17
@@ -15,14 +15,11 @@
 
 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
-
-CFLAGS+= -g -I${incdir} -I/usr/include/libxml2 -L${libdir}
+INCLUDE += -I${incdir} -I/usr/include/libxml2
 
 CFLAGS+= -g -Wstrict-prototypes -Wshadow -fPIC -D_GNU_SOURCE
 
-CFLAGS+= -L ../clulib 
-
-LDFLAGS+= -lclulib -lxml2 -lpthread -ldl -L../../../cman/lib -L../../../ccs/lib -L../../../dlm/lib
+LDFLAGS+= -L ../clulib -L../../../cman/lib -L../../../ccs/lib -L../../../dlm/lib -L${libdir} -lclulib -lxml2 -lpthread -ldl 
 TARGETS=clurgmgrd clurmtabd rg_test
 
 all: ${TARGETS}
@@ -43,7 +40,7 @@
 		resrules.o restree.o fo_domain.o nodeevent.o \
 		rg_event.o watchdog.o rg_state.o \
 	        depends.o ../clulib/libclulib.a
-	$(CC) -o $@ $^ $(INCLUDE) $(CFLAGS) $(LDFLAGS) -lccs -lcman -lpthread -ldlm
+	$(CC) -o $@ $^ $(LDFLAGS) -lccs -lcman -lpthread -ldlm
 
 #
 # Our test program links against the local allocator so that
@@ -61,15 +58,15 @@
 #
 rg_test: rg_locks-noccs.o test-noccs.o reslist-noccs.o \
 		resrules-noccs.o restree-noccs.o fo_domain-noccs.o depends-noccs.o
-	$(CC) -o $@ $^ $(INCLUDE) $(CFLAGS) -llalloc $(LDFLAGS) -lccs -lcman
-	
+	$(CC) -o $@ $^ -llalloc $(LDFLAGS) -lccs -lcman
+
 dtest: rg_locks-noccs.o dtest-noccs.o reslist-noccs.o \
 		resrules.o restree-noccs.o fo_domain-noccs.o depends-noccs.o
-	$(CC) -o $@ $^ $(INCLUDE) $(CFLAGS) -llalloc $(LDFLAGS) -lccs -lcman \
+	$(CC) -o $@ $^ -llalloc $(LDFLAGS) -lccs -lcman \
 		-lreadline -ltermcap
 
 clurmtabd: clurmtabd.o clurmtabd_lib.o
-	$(CC) -o $@ $^ $(INCLUDE) $(CFLAGS) $(LDFLAGS)
+	$(CC) -o $@ $^ $(LDFLAGS)
 
 clean:
 	rm -f *.o $(TARGETS) rg_test
--- cluster/rgmanager/src/daemons/depends.c	2007/02/20 19:57:46	1.2
+++ cluster/rgmanager/src/daemons/depends.c	2007/03/20 17:09:57	1.3
@@ -377,7 +377,6 @@
 static int
 rs_running(char *name, dep_rs_t *sl, int slen)
 {
-	int x;
 	dep_rs_t *rs = NULL;
 	
 	if (name) {
@@ -985,8 +984,7 @@
 dep_check_requires(dep_t **deps, dep_rs_t *state, dep_rs_t *states, int slen)
 {
 	dep_t *dep;
-	dep_node_t *dn;
-	int errors = 0, x, a;
+	int errors = 0, a;
 	
 	/* Check to see if anything depends on this (not-running) resource */
 	list_for(deps, dep, a) {
@@ -2381,7 +2379,7 @@
 dep_apply_trans(dep_t **deps, dep_rs_t *states, int slen, dep_op_t **op_list)
 {
 	dep_op_t *op;
-	int ops = 0, a, x;
+	int ops = 0, x;
 
 	list_for(op_list, op, ops) {
 		for (x = 0; x < slen; x++) {
@@ -2414,8 +2412,7 @@
 {
 	dep_op_t *new_ol = NULL;
 	dep_op_t *op;
-	int x, found;
-	
+
 	if (!*oplist)
 		return;
 	
@@ -2433,8 +2430,7 @@
 {
 	dep_op_t *new_ol = NULL;
 	dep_op_t *op;
-	int x, found;
-	
+
 	if (!*oplist)
 		return;
 	
@@ -2463,7 +2459,7 @@
 		    dep_t **deps, dep_rs_t *_states,
 		    int slen, int *nodes, int nlen, dep_op_t **oplist)
 {
-	int x, ret = -1;
+	int ret = -1;
 	dep_rs_t *state = NULL, *states = NULL;
 	dep_op_t *newop = NULL;
 	int start_score, score;
--- cluster/rgmanager/src/daemons/fo_domain.c	2007/01/26 21:42:30	1.12
+++ cluster/rgmanager/src/daemons/fo_domain.c	2007/03/20 17:09:57	1.13
@@ -129,7 +129,7 @@
 fod_get_domain(int ccsfd, char *base, int idx, fod_t **domains)
 {
 	fod_t *fod;
-	fod_node_t *fodn, *curr;
+	fod_node_t *fodn;
 	char xpath[256];
 	char *ret;
 	int x = 1;
--- cluster/rgmanager/src/daemons/groups.c	2007/03/10 00:20:54	1.28
+++ cluster/rgmanager/src/daemons/groups.c	2007/03/20 17:09:57	1.29
@@ -617,17 +617,17 @@
   Tells us if a resource group can be migrated.
  */
 int
-group_migratory(char *groupname)
+group_migratory(char *groupname, int lock)
 {
 	resource_node_t *rn;
 	resource_t *res;
-	int migrate = 0, x;
+	int migrate = 0, x, ret = 0;
 
-	pthread_rwlock_rdlock(&resource_lock);
+	if (lock)
+		pthread_rwlock_rdlock(&resource_lock);
 
 	res = find_root_by_ref(&_resources, groupname);
 	if (!res) {
-		pthread_rwlock_unlock(&resource_lock);
 		/* Nonexistent or non-TL RG cannot be migrated */
 		return 0;
 	}
@@ -640,26 +640,26 @@
 		}
 	}
 
-	if (!migrate) {
-		pthread_rwlock_unlock(&resource_lock);
-		/* resource rule missing 'migrate' command */
-		return 0;
-	}
+	if (!migrate)
+		goto out_unlock;
 
 	list_do(&_tree, rn) {
 		if (rn->rn_resource == res && rn->rn_child) {
-			pthread_rwlock_unlock(&resource_lock);
 			/* TL service w/ children cannot be migrated */
-			return 0;
+			goto out_unlock;
 		}
 	} while (!list_done(&_tree, rn));
 
-	pthread_rwlock_unlock(&resource_lock);
 
 	/* Ok, we have a migrate option to the resource group,
 	   the resource group has no children, and the resource
 	   group exists.  We're all good */
-	return 1;
+	ret = 1;
+
+out_unlock:
+	if (lock)
+		pthread_rwlock_unlock(&resource_lock);
+	return ret;
 }
 
 
@@ -736,24 +736,40 @@
 	resource_node_t *rn = NULL, *tmp;
 	resource_t *res;
 	char *tgt_name;
-	int ret = RG_ENOSERVICE, x = 0;
+	int ret = RG_ENOSERVICE;
 	cluster_member_list_t *membership;
 
+	if (target <= 0) {
+		clulog(LOG_WARNING,
+		       "Illegal node ID %d during migrate operation\n",
+		       target);
+		return RG_EINVAL;
+	}
+
 	membership = member_list();
-	if (!membership)
+	if (!membership) {
+		clulog(LOG_ERR, "Unable to determine membership during "
+		       "migrate operation\n");
 		return RG_EFAIL;
+	}
 
 	pthread_rwlock_rdlock(&resource_lock);
 	
 	tgt_name = memb_id_to_name(membership, target);
 	if (!tgt_name) {
+		clulog(LOG_WARNING, "Node ID %d not in membership during "
+		       "migrate operation\n", target);
 		ret = RG_EINVAL;
 		goto out;
 	}
 
 	res = find_root_by_ref(&_resources, groupname);
-	if (!res)
+	if (!res) {
+		clulog(LOG_WARNING,
+		       "Unable to find '%s' in resource list during"
+		       "migrate operation\n", groupname);
 		goto out;
+	}
 
 	list_do(&_tree, tmp) {
 		if (tmp->rn_resource == res) {
@@ -762,10 +778,24 @@
 		}
 	} while (!list_done(&_tree, tmp));
 
-	if (!rn)
+	if (!rn) {
+		clulog(LOG_WARNING,
+		       "Unable to find '%s' it top level of resource "
+		       "tree during migrate operation\n", groupname);
 		goto out;
-
-	ret = res_exec(rn, agent_op_str(RS_MIGRATE), tgt_name);
+	}
+	
+	clulog(LOG_NOTICE, "Migrating %s to %s\n", groupname, tgt_name);
+	ret = res_exec(rn, agent_op_str(RS_MIGRATE), tgt_name, 0);
+	if (ret == 0) {
+		clulog(LOG_NOTICE,
+		       "Migration of %s to %s completed\n",
+		       groupname, tgt_name);
+	} else {
+		clulog(LOG_ERR, 
+		       "Migration of %s to %s failed; return code %d\n",
+		       groupname, tgt_name, ret);
+	}
 
 out:
 	pthread_rwlock_unlock(&resource_lock);
--- cluster/rgmanager/src/daemons/main.c	2006/10/23 22:47:01	1.34
+++ cluster/rgmanager/src/daemons/main.c	2007/03/20 17:09:57	1.35
@@ -48,7 +48,6 @@
 int init_resource_groups(int);
 void kill_resource_groups(void);
 void set_my_id(int);
-int eval_groups(int, int, int);
 void flag_shutdown(int sig);
 void hard_exit(void);
 int send_rg_states(msgctx_t *, int);
--- cluster/rgmanager/src/daemons/nodeevent.c	2006/09/27 16:28:41	1.4
+++ cluster/rgmanager/src/daemons/nodeevent.c	2007/03/20 17:09:57	1.5
@@ -137,7 +137,7 @@
 {
 	cman_handle_t ch;
 	int fenced = 0;
-	int fence_time;
+	uint64_t fence_time;
 
 	ch = cman_init(NULL);
 	if (cman_get_fenceinfo(ch, nodeid, &fence_time, &fenced, NULL) < 0)
--- cluster/rgmanager/src/daemons/rg_state.c	2007/03/10 00:20:54	1.29
+++ cluster/rgmanager/src/daemons/rg_state.c	2007/03/20 17:09:57	1.30
@@ -47,7 +47,7 @@
 int get_rg_state(char *servicename, rg_state_t *svcblk);
 void get_recovery_policy(char *rg_name, char *buf, size_t buflen);
 int check_depend_safe(char *servicename);
-int group_migratory(char *servicename);
+int group_migratory(char *servicename, int lock);
 
 
 int 
@@ -815,7 +815,7 @@
 	rg_state_t svcStatus;
 	int ret;
 
-	if (!group_migratory(svcName))
+	if (!group_migratory(svcName, 1))
 		return RG_EINVAL;
 
 	if (rg_lock(svcName, &lockp) < 0) {
@@ -867,8 +867,15 @@
        
 	ret = group_migrate(svcName, target);
 
-	if (ret)
+	if (ret == -1 || ret > 0) {
+		/* XXX run svc_status again here to see if it's still
+		   healthy; if it is, don't FAIL it; it could be that
+		   the target node simply died; in this case, set status
+		   back to started */
+		/* if ret > 0 { svc_status... */
 		svc_fail(svcName);
+		ret = RG_EFAIL;
+	}
 
 	return ret;
 }
@@ -945,6 +952,13 @@
 }
 
 
+int
+svc_status_inquiry(char *svcName)
+{
+	return group_op(svcName, RG_STATUS);
+}
+
+
 /**
  * Stop a cluster service.
  *
--- cluster/rgmanager/src/utils/Makefile	2006/07/19 18:44:58	1.13
+++ cluster/rgmanager/src/utils/Makefile	2007/03/20 17:09:57	1.14
@@ -15,14 +15,13 @@
 
 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
-
-CFLAGS+= -g -I${incdir}
+INCLUDE += -I${incdir}
 
 CFLAGS+= -g -Wstrict-prototypes -Wshadow -fPIC -D_GNU_SOURCE
-
 CFLAGS+= -DPACKAGE_VERSION=\"${RELEASE}\"
 
 LDFLAGS+= -L${libdir} -L../../../cman/lib -L../../../ccs/lib -lcman -lpthread -ldl -lncurses -L../clulib -lclulib -lccs
+
 TARGETS=clubufflush clufindhostname clustat clusvcadm clulog clunfslock
 
 all: ${TARGETS}
@@ -35,22 +34,22 @@
 	${UNINSTALL} $(TARGETS) ${sbindir}
 
 cluarp: cluarp.o
-	$(CC) -o $@ $^ $(INCLUDE) $(CFLAGS) $(LDFLAGS)
+	$(CC) -o $@ $^ $(LDFLAGS)
 
 clulog: clulog.o
-	$(CC) -o $@ $^ $(INCLUDE) $(CFLAGS) $(LDFLAGS)
+	$(CC) -o $@ $^ $(LDFLAGS)
 
 clubufflush: clubufflush.o
-	$(CC) -o $@ $^ $(INCLUDE) $(CFLAGS) $(LDFLAGS)
+	$(CC) -o $@ $^ $(LDFLAGS)
 
 clufindhostname: clufindhostname.o
-	$(CC) -o $@ $^ $(INCLUDE) $(CFLAGS)
+	$(CC) -o $@ $^ $(LDFLAGS)
 
 clustat: clustat.o
-	$(CC) -o $@ $^ $(INCLUDE) $(CFLAGS) $(LDFLAGS)
+	$(CC) -o $@ $^ $(LDFLAGS)
 
 clusvcadm: clusvcadm.o
-	$(CC) -o $@ $^ $(INCLUDE) $(CFLAGS) $(LDFLAGS)
+	$(CC) -o $@ $^ $(LDFLAGS)
 
 clunfslock: clunfslock.sh
 	cp clunfslock.sh clunfslock
--- cluster/rgmanager/src/utils/clufindhostname.c	2006/07/12 15:01:11	1.4
+++ cluster/rgmanager/src/utils/clufindhostname.c	2007/03/20 17:09:57	1.5
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <arpa/inet.h>
+#include <string.h>
 
 void
 usage(char *progname)
--- cluster/rgmanager/src/utils/clusvcadm.c	2007/03/10 00:20:54	1.17
+++ cluster/rgmanager/src/utils/clusvcadm.c	2007/03/20 17:09:57	1.18
@@ -159,7 +159,7 @@
        " on <member>\n", name);
 printf("       %s -r <group> -m <member> Relocate <group> [to <member>]\n",
 	       name);
-printf("       %s -M <group> -m <member> Migrate <group> [to <member>]\n",
+printf("       %s -M <group> -m <member> Migrate <group> to <member>\n",
 	       name);
 printf("                                 (e.g. for live migration of VMs)\n");
 printf("       %s -q                     Quiet operation\n", name);
@@ -310,6 +310,11 @@
 		return 1;
 	}
 
+	if (action == RG_MIGRATE && !node_specified) {
+		printf("Migration requires a target cluster member\n");
+		return 1;
+	}
+
 	if (!strchr(svcname,':')) {
 		snprintf(realsvcname, sizeof(realsvcname), "service:%s";,
 			 svcname);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]