cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] cluster/rgmanager/src daemons/resrules.c daemo ...
@ 2007-04-04 19:22 lhh
  0 siblings, 0 replies; 2+ messages in thread
From: lhh @ 2007-04-04 19:22 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	lhh at sourceware.org	2007-04-04 20:22:29

Modified files:
	rgmanager/src/daemons: resrules.c restree.c 
	rgmanager/src/resources: clusterfs.sh 

Log message:
	allow ocfs[2] to work with the clusterfs resource agent.  Also, commit patch which corrects interval processing for status operations

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/resrules.c.diff?cvsroot=cluster&r1=1.20&r2=1.21
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/restree.c.diff?cvsroot=cluster&r1=1.28&r2=1.29
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/clusterfs.sh.diff?cvsroot=cluster&r1=1.15&r2=1.16

--- cluster/rgmanager/src/daemons/resrules.c	2007/03/27 19:33:20	1.20
+++ cluster/rgmanager/src/daemons/resrules.c	2007/04/04 19:22:29	1.21
@@ -274,6 +274,7 @@
 		acts[0].ra_depth = depth;
 		acts[0].ra_timeout = timeout;
 		acts[0].ra_interval = interval;
+		acts[0].ra_last = 0;
 		acts[1].ra_name = NULL;
 
 		*actsp = acts;
@@ -297,6 +298,7 @@
 				       (int)interval);
 				acts[x].ra_interval = interval;
 			}
+			acts[x].ra_last = 0;
 			printf("\n");
 			replace = 1;
 		}
@@ -318,6 +320,7 @@
 	acts[x].ra_depth = depth;
 	acts[x].ra_timeout = timeout;
 	acts[x].ra_interval = interval;
+	acts[x].ra_last = 0;
 
 	acts[x+1].ra_name = NULL;
 
--- cluster/rgmanager/src/daemons/restree.c	2007/03/23 00:00:07	1.28
+++ cluster/rgmanager/src/daemons/restree.c	2007/04/04 19:22:29	1.29
@@ -1019,25 +1019,39 @@
 
 	now = time(NULL);
 
-       for (; node->rn_actions[x].ra_name; x++) {
+	for (; node->rn_actions[x].ra_name; x++) {
 		if (!has_recover &&
-                   !strcmp(node->rn_actions[x].ra_name, "recover")) {
+		    !strcmp(node->rn_actions[x].ra_name, "recover")) {
 			has_recover = 1;
 			continue;
 		}
 
-               if (strcmp(node->rn_actions[x].ra_name, "status"))
+		if (strcmp(node->rn_actions[x].ra_name, "status"))
 			continue;
 
-               delta = now - node->rn_actions[x].ra_last;
+		/* If a status check has never been done, reset its status. */
+		if (!node->rn_actions[x].ra_last) {
+			node->rn_actions[x].ra_last = now;
+			continue;
+		}
+
+		delta = now - node->rn_actions[x].ra_last;
 
-		/* Ok, it's a 'monitor' action. See if enough time has
-		   elapsed for a given type of monitoring action */
-               if (delta < node->rn_actions[x].ra_interval)
+		/*
+		printf("%s:%s %s level %d interval = %d  elapsed = %d\n",
+			node->rn_resource->r_rule->rr_type,
+			node->rn_resource->r_attrs->ra_value,
+			node->rn_actions[x].ra_name, node->rn_actions[x].ra_depth,
+			(int)node->rn_actions[x].ra_interval, (int)delta);
+		 */
+
+		/* Ok, it's a 'status' action. See if enough time has
+		   elapsed for a given type of status action */
+		if (delta < node->rn_actions[x].ra_interval)
 			continue;
 
 		if (idx == -1 ||
-                   node->rn_actions[x].ra_depth > node->rn_actions[idx].ra_depth)
+		    node->rn_actions[x].ra_depth > node->rn_actions[idx].ra_depth)
 			idx = x;
 	}
 
@@ -1045,7 +1059,27 @@
 	if (idx == -1)
 		return 0;
 
-       node->rn_actions[idx].ra_last = now;
+ 	/* Clear all check levels lower than us */
+ 	for (x = 0; node->rn_actions[x].ra_name; x++) {
+ 		if (x == idx) {
+ 			node->rn_actions[idx].ra_last = now;
+ 			continue;
+ 		}
+ 		if (strcmp(node->rn_actions[x].ra_name, "status"))
+ 			continue;
+ 
+ 		if (node->rn_actions[x].ra_depth <
+ 		    node->rn_actions[idx].ra_depth)
+ 			node->rn_actions[x].ra_last = now;
+ 	}
+ 
+ 	/*printf("-> %s:%s %s level %d interval = %d\n",
+ 		node->rn_resource->r_rule->rr_type,
+ 		node->rn_resource->r_attrs->ra_value,
+ 		node->rn_actions[idx].ra_name,
+ 		node->rn_actions[idx].ra_depth,
+ 		(int)node->rn_actions[idx].ra_interval);*/
+ 
 	if ((x = res_exec(node, agent_op_str(RS_STATUS), NULL,
                          node->rn_actions[idx].ra_depth)) == 0)
 		return 0;
--- cluster/rgmanager/src/resources/clusterfs.sh	2006/10/25 15:38:55	1.15
+++ cluster/rgmanager/src/resources/clusterfs.sh	2007/04/04 19:22:29	1.16
@@ -279,6 +279,9 @@
 	gfs)
 		return $OCF_SUCCESS
 		;;
+	ocfs|ocfs2)
+		return $OCF_SUCCESS
+		;;
 	*)
 		ocf_log err "File system type $OCF_RESKEY_fstype not supported"
 		return $OCF_ERR_ARGS



^ permalink raw reply	[flat|nested] 2+ messages in thread
* [Cluster-devel] cluster/rgmanager/src daemons/resrules.c daemo ...
@ 2007-01-26 20:41 lhh
  0 siblings, 0 replies; 2+ messages in thread
From: lhh @ 2007-01-26 20:41 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	lhh at sourceware.org	2007-01-26 20:41:41

Modified files:
	rgmanager/src/daemons: resrules.c reslist.c Makefile 
	rgmanager/src/utils: clustat.c 

Log message:
	Fix #223230; allow <action> spec. in cluster.conf.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/resrules.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.16&r2=1.16.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/reslist.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.14&r2=1.14.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/Makefile.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.14&r2=1.14.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/utils/clustat.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.25.2.2&r2=1.25.2.3

--- cluster/rgmanager/src/daemons/resrules.c	2006/10/20 20:59:49	1.16
+++ cluster/rgmanager/src/daemons/resrules.c	2007/01/26 20:41:40	1.16.2.1
@@ -31,7 +31,9 @@
 #include <pthread.h>
 #include <dirent.h>
 #include <libgen.h>
+#ifndef NO_CCS
 #include <clulog.h>
+#endif
 
 
 /**
@@ -49,8 +51,13 @@
 
 	list_do(rulelist, curr) {
 		if (!strcmp(newrule->rr_type, curr->rr_type)) {
+#ifdef NO_CCS
 			fprintf(stderr, "Error storing %s: Duplicate\n",
 				newrule->rr_type);
+#else
+			clulog(LOG_ERR, "Error storing %s: Duplicate\n",
+				newrule->rr_type);
+#endif
 			return -1;
 		}
 
@@ -218,17 +225,36 @@
 }
 
 
+/**
+ * Store a resource action
+ * @param actsp		Action array; may be modified and returned!
+ * @param name		Name of the action
+ * @param depth		Resource depth (status/monitor; -1 means *ALL LEVELS*
+ * 			... this means that only the highest-level check depth
+ * 			will ever be performed!)
+ * @param timeout	Timeout (not used)
+ * @param interval	Time interval for status/monitor
+ * @return		0 on success, -1 on failure
+ * 
+ */
 int
 store_action(resource_act_t **actsp, char *name, int depth,
 	     int timeout, int interval)
 {
-	int x = 0;
+	int x = 0, replace = 0;
 	resource_act_t *acts = *actsp;
 
 	if (!name)
 		return -1;
+	
+	if (depth < 0 && timeout < 0 && interval < 0)
+		return -1;
 
 	if (!acts) {
+		/* Can't create with anything < 0 */
+		if (depth < 0 || timeout < 0 || interval < 0)
+			return -1;
+		
 		acts = malloc(sizeof(resource_act_t) * 2);
 		if (!acts)
 			return -1;
@@ -244,17 +270,38 @@
 
 	for (x = 0; acts[x].ra_name; x++) {
 		if (!strcmp(acts[x].ra_name, name) &&
-		    depth == acts[x].ra_depth) {
-			printf("Skipping duplicate action/depth %s/%d\n",
-			       name, depth);
-			return -1;
+		    (depth == acts[x].ra_depth || depth == -1)) {
+			printf("Replacing action '%s' depth %d: ",
+			       name, acts[x].ra_depth);
+			if (timeout >= 0) {
+				printf("timeout: %d->%d ",
+				       (int)acts[x].ra_timeout,
+				       (int)timeout);
+				acts[x].ra_timeout = timeout;
+			}
+			if (interval >= 0) {
+				printf("interval: %d->%d",
+				       (int)acts[x].ra_interval,
+				       (int)interval);
+				acts[x].ra_interval = interval;
+			}
+			printf("\n");
+			replace = 1;
 		}
 	}
+	
+	if (replace)
+		/* If we replaced something, we're done */
+		return 1;
+	
+	/* Can't create with anything < 0 */
+	if (depth < 0 || timeout < 0 || interval < 0)
+		return -1;
 
 	acts = realloc(acts, sizeof(resource_act_t) * (x+2));
 	if (!acts)
 		return -1;
-
+	
 	acts[x].ra_name = name;
 	acts[x].ra_depth = depth;
 	acts[x].ra_timeout = timeout;
@@ -267,6 +314,7 @@
 }
 
 
+
 void
 _get_actions(xmlDocPtr doc, xmlXPathContextPtr ctx, char *base,
 		 resource_rule_t *rr)
@@ -294,8 +342,8 @@
 		ret = xpath_get_one(doc, ctx, xpath);
 		if (ret) {
 			timeout = expand_time(ret);
-			if (interval < 0)
-				interval = 0;
+			if (timeout < 0)
+				timeout = 0;
 			free(ret);
 		}
 
@@ -322,9 +370,8 @@
 		}
 
 		if (store_action(&rr->rr_actions, act, depth, timeout,
-				 interval) < 0)
+				 interval) != 0)
 			free(act);
-		
 	} while (1);
 }
 
@@ -866,6 +913,20 @@
 		type = xpath_get_one(doc, ctx, base);
 		if (!type)
 			break;
+		
+		if (!strcasecmp(type, "action")) {
+#ifdef NO_CCS
+			fprintf(stderr,
+				"Error: Resource type '%s' is reserved",
+				type);
+#else
+			clulog(LOG_ERR,
+				"Error: Resource type '%s' is reserved",
+				type);
+#endif
+			free(type);
+			break;
+		}
 
 		rr = malloc(sizeof(*rr));
 		if (!rr)
--- cluster/rgmanager/src/daemons/reslist.c	2006/07/11 23:52:41	1.14
+++ cluster/rgmanager/src/daemons/reslist.c	2007/01/26 20:41:40	1.14.2.1
@@ -28,6 +28,9 @@
 #include <list.h>
 #include <reslist.h>
 #include <pthread.h>
+#ifndef NO_CCS
+#include <clulog.h>
+#endif
 
 
 char *attr_value(resource_node_t *node, char *attrname);
@@ -360,12 +363,29 @@
 					/*
 					   Unique/primary is not unique
 					 */
-					printf("Unique/primary not unique "
-					       "type %s, %s=%s\n",
+#ifdef NO_CCS
+					printf("Error: "
+                                               "%s attribute collision. "
+                                               "type=%s attr=%s value=%s\n",
+					       (newres->r_attrs[x].ra_flags&
+                                                RA_PRIMARY)?"Primary":
+                                               "Unique",
+					       newres->r_rule->rr_type,
+					       newres->r_attrs[x].ra_name,
+					       newres->r_attrs[x].ra_value
+					       );
+#else 
+					clulog(LOG_ERR,
+                                               "%s attribute collision. "
+                                               "type=%s attr=%s value=%s\n",
+					       (newres->r_attrs[x].ra_flags&
+                                                RA_PRIMARY)?"Primary":
+                                               "Unique",
 					       newres->r_rule->rr_type,
 					       newres->r_attrs[x].ra_name,
 					       newres->r_attrs[x].ra_value
 					       );
+#endif
 					return -1;
 				}
 				break;
@@ -542,6 +562,83 @@
 }
 
 
+/* Copied from resrules.c -- _get_actions */
+void
+_get_actions_ccs(int ccsfd, char *base, resource_t *res)
+{
+	char xpath[256];
+	int idx = 0;
+	char *act, *ret;
+	int interval, timeout, depth;
+
+	do {
+		/* setting these to -1 prevents overwriting with 0 */
+		interval = -1;
+		depth = -1;
+		act = NULL;
+		timeout = -1;
+
+		snprintf(xpath, sizeof(xpath),
+			 "%s/action[%d]/@name", base, ++idx);
+
+#ifndef NO_CCS
+		if (ccs_get(ccsfd, xpath, &act) != 0)
+#else
+		if (conf_get(xpath, &act) != 0)
+#endif
+			break;
+
+		snprintf(xpath, sizeof(xpath),
+			 "%s/action[%d]/@timeout", base, idx);
+#ifndef NO_CCS
+		if (ccs_get(ccsfd, xpath, &ret) == 0 && ret) {
+#else
+		if (conf_get(xpath, &ret) == 0 && ret) {
+#endif
+			timeout = expand_time(ret);
+			if (timeout < 0)
+				timeout = 0;
+			free(ret);
+		}
+
+		snprintf(xpath, sizeof(xpath),
+			 "%s/action[%d]/@interval", base, idx);
+#ifndef NO_CCS
+		if (ccs_get(ccsfd, xpath, &ret) == 0 && ret) {
+#else
+		if (conf_get(xpath, &ret) == 0 && ret) {
+#endif
+			interval = expand_time(ret);
+			if (interval < 0)
+				interval = 0;
+			free(ret);
+		}
+
+		if (!strcmp(act, "status") || !strcmp(act, "monitor")) {
+			snprintf(xpath, sizeof(xpath),
+				 "%s/action[%d]/@depth", base, idx);
+#ifndef NO_CCS
+			if (ccs_get(ccsfd, xpath, &ret) == 0 && ret) {
+#else
+			if (conf_get(xpath, &ret) == 0 && ret) {
+#endif
+				depth = atoi(ret);
+				if (depth < 0)
+					depth = 0;
+				
+				/* */
+				if (ret[0] == '*')
+					depth = -1;
+				free(ret);
+			}
+		}
+
+		if (store_action(&res->r_actions, act, depth, timeout,
+				 interval) != 0)
+			free(act);
+	} while (1);
+}
+
 
 /**
    Try to load all the attributes in our rule set.  If none are found,
@@ -647,12 +744,12 @@
 	}
 
 	if (!found) {
-		//printf("No attributes found for %s\n", base);
 		destroy_resource(res);
 		return NULL;
 	}
 
 	res->r_actions = act_dup(rule->rr_actions);
+	_get_actions_ccs(ccsfd, base, res);
 
 	return res;
 }
@@ -679,14 +776,21 @@
 		for (resID = 1; ; resID++) {
 			snprintf(tok, sizeof(tok), RESOURCE_BASE "/%s[%d]",
 				 currule->rr_type, resID);
-
+			
 			newres = load_resource(ccsfd, currule, tok);
 			if (!newres)
 				break;
 
 		       if (store_resource(reslist, newres) != 0) {
+#ifdef NO_CCS
 	       		       printf("Error storing %s resource\n",
 				      newres->r_rule->rr_type);
+#else
+	       		       clulog(LOG_ERR,
+				      "Error storing %s resource\n",
+				      newres->r_rule->rr_type);
+#endif
+
 			       destroy_resource(newres);
 		       }
 
--- cluster/rgmanager/src/daemons/Makefile	2006/07/12 14:38:01	1.14
+++ cluster/rgmanager/src/daemons/Makefile	2007/01/26 20:41:40	1.14.2.1
@@ -59,7 +59,7 @@
 # packages should run 'make check' as part of the build process.
 #
 rg_test: rg_locks-noccs.o test-noccs.o reslist-noccs.o \
-		resrules.o restree-noccs.o fo_domain-noccs.o
+		resrules-noccs.o restree-noccs.o fo_domain-noccs.o
 	$(CC) -o $@ $^ $(INCLUDE) $(CFLAGS) -llalloc $(LDFLAGS) -lccs -lcman
 
 clurmtabd: clurmtabd.o clurmtabd_lib.o
--- cluster/rgmanager/src/utils/clustat.c	2007/01/17 16:20:29	1.25.2.2
+++ cluster/rgmanager/src/utils/clustat.c	2007/01/26 20:41:41	1.25.2.3
@@ -20,6 +20,7 @@
 #define FLAG_LOCAL 0x2
 #define FLAG_RGMGR 0x4
 #define FLAG_NOCFG 0x8	/* Shouldn't happen */
+#define FLAG_QDISK 0x10
 
 #define RG_VERBOSE 0x1
 
@@ -342,8 +343,8 @@
 cluster_member_list_t *
 add_missing(cluster_member_list_t *all, cluster_member_list_t *these)
 {
-	int x, y;
-	cman_node_t *m, *new;
+	int x, y, addflag;
+	cman_node_t *m, *nn;
 
 	if (!these)
 		return all;
@@ -356,12 +357,8 @@
 				    these->cml_members[x].cn_name))
                         	m = &all->cml_members[y];
 		}
-
+        	
 		if (!m) {
-			printf("%s not found\n", these->cml_members[x].cn_name);
-			/* WTF? It's not in our config */
-			printf("realloc %d\n", (int)((all->cml_count+1) *
-			       sizeof(cman_node_t)));
 			all->cml_members = realloc(all->cml_members,
 						   (all->cml_count+1) *
 						   sizeof(cman_node_t));
@@ -370,15 +367,21 @@
 				exit(1);
 			}
 			
-			new = &all->cml_members[all->cml_count];
+			nn = &all->cml_members[all->cml_count];
 
-			memcpy(new, &these->cml_members[x],
+			memcpy(nn, &these->cml_members[x],
 			       sizeof(cman_node_t));
+			
+			if (nn->cn_nodeid == 0) { /* quorum disk? */
+				addflag = FLAG_QDISK;
+			} else {
+				addflag = FLAG_NOCFG;
+			}
 
-			if (new->cn_member) {
-				new->cn_member = FLAG_UP | FLAG_NOCFG;
+			if (nn->cn_member) {
+				nn->cn_member = FLAG_UP | addflag;
 			} else {
-				new->cn_member = FLAG_NOCFG;
+				nn->cn_member = addflag;
 			}
 			++all->cml_count;
 
@@ -612,9 +615,12 @@
 	
 	if (node->cn_member & FLAG_NOCFG)
 		printf(", Estranged");
-
+	
 	if (node->cn_member & FLAG_RGMGR)
 		printf(", rgmanager");
+	
+	if (node->cn_member & FLAG_QDISK)
+		printf(", Quorum Disk");
 
 	printf("\n");
 		
@@ -626,12 +632,13 @@
 xml_member_state(cman_node_t *node)
 {
 	printf("    <node name=\"%s\" state=\"%d\" local=\"%d\" "
-	       "estranged=\"%d\" rgmanager=\"%d\" nodeid=\"0x%08x\"/>\n",
+	       "estranged=\"%d\" rgmanager=\"%d\" qdisk=\"%d\" nodeid=\"0x%08x\"/>\n",
 	       node->cn_name,
 	       !!(node->cn_member & FLAG_UP),
 	       !!(node->cn_member & FLAG_LOCAL),
 	       !!(node->cn_member & FLAG_NOCFG),
 	       !!(node->cn_member & FLAG_RGMGR),
+	       !!(node->cn_member & FLAG_QDISK),
 	       (uint32_t)((node->cn_nodeid      )&0xffffffff));
 }
 



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-04-04 19:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-04 19:22 [Cluster-devel] cluster/rgmanager/src daemons/resrules.c daemo lhh
  -- strict thread matches above, loose matches on Subject: below --
2007-01-26 20:41 lhh

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 NNTP newsgroup(s).