cluster/rgmanager/src daemons/resrules.c daemo ...
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
rgmanager/src/daemons/resrules.c +71 -10
@@ -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)
rgmanager/src/daemons/reslist.c +108 -4
158 lines not on this page · raw message
rgmanager/src/daemons/Makefile +1 -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
rgmanager/src/utils/clustat.c +21 -14
@@ -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 )); }