From: lhh@sourceware.org <lhh@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/rgmanager include/members.h include/re ...
Date: 20 Mar 2007 17:09:14 -0000 [thread overview]
Message-ID: <20070320170914.27018.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: lhh at sourceware.org 2007-03-20 17:09:12
Modified files:
rgmanager/include: members.h res-ocf.h resgroup.h reslist.h
rgmanager/src/clulib: Makefile rg_strings.c
rgmanager/src/daemons: Makefile groups.c main.c nodeevent.c
restree.c rg_state.c rg_thread.c test.c
rgmanager/src/resources: vm.sh
rgmanager/src/utils: Makefile clufindhostname.c clusvcadm.c
Log message:
Add logging to migration path. 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&only_with_tag=RHEL5&r1=1.3&r2=1.3.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/res-ocf.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1&r2=1.1.16.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/resgroup.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.15.2.2&r2=1.15.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/reslist.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.15&r2=1.15.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/Makefile.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.10&r2=1.10.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/rg_strings.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.5.2.1&r2=1.5.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/Makefile.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.14.2.1&r2=1.14.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/groups.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.25.2.2&r2=1.25.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/main.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.34&r2=1.34.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/nodeevent.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.4&r2=1.4.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/restree.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.23&r2=1.23.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/rg_state.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.24.2.4&r2=1.24.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/rg_thread.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.15.2.2&r2=1.15.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/test.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.6&r2=1.6.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/vm.sh.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/utils/Makefile.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.13&r2=1.13.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/utils/clufindhostname.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.4&r2=1.4.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/utils/clusvcadm.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.12.2.2&r2=1.12.2.3
--- cluster/rgmanager/include/members.h 2006/09/27 16:28:41 1.3
+++ cluster/rgmanager/include/members.h 2007/03/20 17:09:11 1.3.2.1
@@ -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/res-ocf.h 2004/08/13 15:36:50 1.1
+++ cluster/rgmanager/include/res-ocf.h 2007/03/20 17:09:11 1.1.16.1
@@ -45,4 +45,22 @@
#define OCF_RA_NOT_RUNNING 7
#define OCF_RA_MAX 7
+/*
+ Resource operations - not ocf-specified
+ */
+#define RS_START (0)
+#define RS_STOP (1)
+#define RS_STATUS (2)
+#define RS_RESINFO (3)
+#define RS_RESTART (4)
+#define RS_RELOAD (5)
+#define RS_CONDRESTART (6)
+#define RS_RECOVER (7)
+#define RS_CONDSTART (8) /** Start if flagged with RF_NEEDSTART */
+#define RS_CONDSTOP (9) /** STOP if flagged with RF_NEEDSTOP */
+#define RS_MONITOR (10)
+#define RS_META_DATA (11)
+#define RS_VALIDATE (12)
+#define RS_MIGRATE (13)
+
#endif
--- cluster/rgmanager/include/resgroup.h 2006/12/14 22:17:43 1.15.2.2
+++ cluster/rgmanager/include/resgroup.h 2007/03/20 17:09:11 1.15.2.3
@@ -81,9 +81,7 @@
#define RG_MIGRATE 22
#define RG_NONE 999
-extern const char *rg_req_strings[];
-
-#define rg_req_str(req) (rg_req_strings[req])
+const char *rg_req_str(int req);
int handle_relocate_req(char *svcName, int request, int preferred_target,
int *new_owner);
@@ -107,9 +105,11 @@
#define DEFAULT_CHECK_INTERVAL 10
-extern const char *rg_state_strings[];
+const char *rg_state_str(int val);
+const char *agent_op_str(int val);
-#define rg_state_str(state) (rg_state_strings[state - RG_STATE_BASE])
+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);
@@ -121,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);
@@ -175,7 +176,7 @@
#define RG_YES 1
#define RG_NO 2
-char *rg_strerror(int val);
+const char *rg_strerror(int val);
/*
--- cluster/rgmanager/include/reslist.h 2006/09/27 16:28:41 1.15
+++ cluster/rgmanager/include/reslist.h 2007/03/20 17:09:11 1.15.2.1
@@ -40,25 +40,6 @@
#define RES_STARTED (1)
#define RES_FAILED (2)
-/*
- Resource operations
- */
-#define RS_START (0)
-#define RS_STOP (1)
-#define RS_STATUS (2)
-#define RS_RESINFO (3)
-#define RS_RESTART (4)
-#define RS_RELOAD (5)
-#define RS_CONDRESTART (6)
-#define RS_RECOVER (7)
-#define RS_CONDSTART (8) /** Start if flagged with RF_NEEDSTART */
-#define RS_CONDSTOP (9) /** STOP if flagged with RF_NEEDSTOP */
-#define RS_MONITOR (10)
-#define RS_META_DATA (11)
-#define RS_VALIDATE (12)
-#define RS_MIGRATE (13)
-
-
#ifndef SHAREDIR
#define SHAREDIR "/usr/share/rgmanager"
#endif
@@ -159,7 +140,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:11 1.10.2.1
@@ -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/clulib/rg_strings.c 2006/12/14 22:17:43 1.5.2.1
+++ cluster/rgmanager/src/clulib/rg_strings.c 2007/03/20 17:09:11 1.5.2.2
@@ -16,9 +16,16 @@
Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
MA 02139, USA.
*/
+#include <res-ocf.h>
#include <resgroup.h>
-struct { int val; char *str; } rg_error_strings[] = {
+struct string_val {
+ int val;
+ char *str;
+};
+
+
+const struct string_val rg_error_strings[] = {
{ RG_ERUN, "Service is already running" },
{ RG_EQUORUM, "Operation requires quorum" },
{ RG_EINVAL, "Invalid operation for resource" },
@@ -36,53 +43,107 @@
};
-char *rg_strerror(int err)
+const struct string_val rg_req_strings[] = {
+ {RG_SUCCESS, "success" },
+ {RG_FAIL, "fail"},
+ {RG_START, "start"},
+ {RG_STOP, "stop"},
+ {RG_STATUS, "status"},
+ {RG_DISABLE, "disable"},
+ {RG_STOP_RECOVER, "stop (recovery)"},
+ {RG_START_RECOVER, "start (recovery)"},
+ {RG_RESTART, "restart"},
+ {RG_EXITING, "exiting"},
+ {RG_INIT, "initialize"},
+ {RG_ENABLE, "enable"},
+ {RG_STATUS_NODE, "status inquiry"},
+ {RG_RELOCATE, "relocate"},
+ {RG_CONDSTOP, "conditional stop"},
+ {RG_CONDSTART, "conditional start"},
+ {RG_START_REMOTE,"remote start"},
+ {RG_STOP_USER, "user stop"},
+ {RG_STOP_EXITING, "stop (shutdown)"},
+ {RG_LOCK, "locking"},
+ {RG_UNLOCK, "unlocking"},
+ {RG_QUERY_LOCK, "lock status inquiry"},
+ {RG_MIGRATE, "migrate"},
+ {RG_NONE, "none"},
+ {0, NULL}
+};
+
+
+const struct string_val rg_state_strings[] = {
+ {RG_STATE_STOPPED, "stopped"},
+ {RG_STATE_STARTING, "starting"},
+ {RG_STATE_STARTED, "started"},
+ {RG_STATE_STOPPING, "stopping"},
+ {RG_STATE_FAILED, "failed"},
+ {RG_STATE_UNINITIALIZED, "uninitialized"},
+ {RG_STATE_CHECK, "checking"},
+ {RG_STATE_ERROR, "recoverable"},
+ {RG_STATE_RECOVER, "recovering"},
+ {RG_STATE_DISABLED, "disabled"},
+ {RG_STATE_MIGRATE, "migrating"},
+ {0, NULL}
+};
+
+
+const struct string_val agent_ops[] = {
+ {RS_START, "start"},
+ {RS_STOP, "stop"},
+ {RS_STATUS, "status"},
+ {RS_RESINFO, "resinfo"},
+ {RS_RESTART, "restart"},
+ {RS_RELOAD, "reload"},
+ {RS_CONDRESTART, "condrestart"}, /* Unused */
+ {RS_RECOVER, "recover"},
+ {RS_CONDSTART, "condstart"},
+ {RS_CONDSTOP, "condstop"},
+ {RS_MONITOR, "monitor"},
+ {RS_META_DATA, "meta-data"}, /* printenv */
+ {RS_VALIDATE, "validate-all"},
+ {RS_MIGRATE, "migrate"},
+ {0 , NULL}
+};
+
+
+static inline const char *
+rg_search_table(const struct string_val *table, int val)
{
int x;
- for (x = 0; rg_error_strings[x].str != NULL; x++) {
- if (rg_error_strings[x].val == err) {
- return rg_error_strings[x].str;
+ for (x = 0; table[x].str != NULL; x++) {
+ if (table[x].val == val) {
+ return table[x].str;
}
}
return "Unknown";
}
+
+
+const char *
+rg_strerror(int val)
+{
+ return rg_search_table(rg_error_strings, val);
+}
+const char *
+rg_state_str(int val)
+{
+ return rg_search_table(rg_state_strings, val);
+}
-const char *rg_state_strings[] = {
- "stopped",
- "starting",
- "started",
- "stopping",
- "failed",
- "uninitialized",
- "checking",
- "recoverable",
- "recovering",
- "disabled",
- ""
-};
-const char *rg_req_strings[] = {
- "success",
- "fail",
- "start",
- "stop",
- "status",
- "disable",
- "stop (recovery)",
- "start (recovery)",
- "restart",
- "exiting",
- "initialize",
- "enable",
- "status inquiry",
- "relocate",
- "conditional stop",
- "conditional start",
- "remote start",
- "user stop",
- ""
-};
+const char *
+rg_req_str(int val)
+{
+ return rg_search_table(rg_req_strings, val);
+}
+
+const char *
+agent_op_str(int val)
+{
+ return rg_search_table(agent_ops, val);
+}
--- cluster/rgmanager/src/daemons/Makefile 2007/01/26 20:41:40 1.14.2.1
+++ cluster/rgmanager/src/daemons/Makefile 2007/03/20 17:09:11 1.14.2.2
@@ -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}
--- cluster/rgmanager/src/daemons/groups.c 2007/02/21 20:46:49 1.25.2.2
+++ cluster/rgmanager/src/daemons/groups.c 2007/03/20 17:09:11 1.25.2.3
@@ -36,7 +36,6 @@
#define cn_svccount cn_address.cna_address[0] /* Theses are uint8_t size */
#define cn_svcexcl cn_address.cna_address[1]
-extern char *res_ops[];
static int config_version = 0;
static resource_t *_resources = NULL;
static resource_rule_t *_rules = NULL;
@@ -618,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;
}
@@ -641,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;
}
@@ -734,27 +733,69 @@
int
group_migrate(char *groupname, int target)
{
+ resource_node_t *rn = NULL, *tmp;
resource_t *res;
char *tgt_name;
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;
+ }
- if (!tgt_name) {
- ret = RG_EINVAL;
+ list_do(&_tree, tmp) {
+ if (tmp->rn_resource == res) {
+ rn = tmp;
+ break;
+ }
+ } while (!list_done(&_tree, tmp));
+
+ 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(res, res_ops[RG_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);
@@ -1009,7 +1050,8 @@
}
if (svcblk.rs_owner != my_id() ||
- svcblk.rs_state != RG_STATE_STARTED)
+ (svcblk.rs_state != RG_STATE_STARTED &&
+ svcblk.rs_state != RG_STATE_MIGRATE))
continue;
rt_enqueue_request(rg, RG_STATUS,
--- 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:11 1.34.2.1
@@ -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:11 1.4.2.1
@@ -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/restree.c 2006/09/21 18:04:04 1.23
+++ cluster/rgmanager/src/daemons/restree.c 2007/03/20 17:09:11 1.23.2.1
@@ -60,23 +60,6 @@
time_t get_time(char *action, int depth, resource_node_t *node);
-const char *res_ops[] = {
- "start",
- "stop",
- "status",
- "resinfo",
- "restart",
- "reload",
- "condrestart", /* Unused */
- "recover",
- "condstart",
- "condstop",
- "monitor",
- "meta-data", /* printenv */
- "validate-all",
- "migrate"
-};
-
const char *ocf_errors[] = {
"success", // 0
@@ -97,14 +80,13 @@
const char *
ocf_strerror(int ret)
{
- if (ret < OCF_RA_MAX)
+ if (ret >= 0 && ret < OCF_RA_MAX)
return ocf_errors[ret];
return "unspecified";
}
-
/**
Destroys an environment variable array.
@@ -360,7 +342,7 @@
#endif
#if 0
printf("Exec of script %s, action %s type %s\n",
- res->r_rule->rr_agent, res_ops[op],
+ res->r_rule->rr_agent, agent_op_str(op),
res->r_rule->rr_type);
#endif
@@ -701,7 +683,7 @@
#if 0
printf("%s children of %s type %s (level %d)\n",
- res_ops[op],
+ agent_op_str(op),
node->rn_resource->r_rule->rr_type,
rule->rr_childtypes[x].rc_name, l);
#endif
@@ -744,7 +726,7 @@
/*
printf("%s children of %s type %s (default level)\n",
- res_ops[op],
+ agent_op_str(op),
node->rn_resource->r_rule->rr_type,
rule->rr_childtypes[x].rc_name);
*/
@@ -852,7 +834,7 @@
return 0;
node->rn_actions[idx].ra_last = now;
- if ((x = res_exec(node, res_ops[RS_STATUS], NULL,
+ if ((x = res_exec(node, agent_op_str(RS_STATUS), NULL,
node->rn_actions[idx].ra_depth)) == 0)
return 0;
@@ -860,7 +842,7 @@
return x;
/* Strange/failed status. Try to recover inline. */
- if ((x = res_exec(node, res_ops[RS_RECOVER], NULL, 0)) == 0)
+ if ((x = res_exec(node, agent_op_str(RS_RECOVER), NULL, 0)) == 0)
return 0;
return x;
@@ -965,7 +947,7 @@
me = !first || (node->rn_resource == first);
/*
- printf("begin %s: %s %s [0x%x]\n", res_ops[op],
+ printf("begin %s: %s %s [0x%x]\n", agent_op_str(op),
node->rn_resource->r_rule->rr_type,
primary_attr_value(node->rn_resource),
node->rn_flags);
@@ -1010,7 +992,7 @@
if (me && (op == RS_START)) {
node->rn_flags &= ~RF_NEEDSTART;
- rv = res_exec(node, res_ops[op], NULL, 0);
+ rv = res_exec(node, agent_op_str(op), NULL, 0);
if (rv != 0) {
node->rn_state = RES_FAILED;
return rv;
@@ -1034,7 +1016,7 @@
/* Stop/status/etc stops after children have stopped */
if (me && (op == RS_STOP)) {
node->rn_flags &= ~RF_NEEDSTOP;
- rv = res_exec(node, res_ops[op], NULL, 0);
+ rv = res_exec(node, agent_op_str(op), NULL, 0);
if (rv != 0) {
node->rn_state = RES_FAILED;
@@ -1054,7 +1036,7 @@
}
/*
- printf("end %s: %s %s\n", res_ops[op],
+ printf("end %s: %s %s\n", agent_op_str(op),
node->rn_resource->r_rule->rr_type,
primary_attr_value(node->rn_resource));
*/
--- cluster/rgmanager/src/daemons/rg_state.c 2007/02/20 19:55:12 1.24.2.4
+++ cluster/rgmanager/src/daemons/rg_state.c 2007/03/20 17:09:11 1.24.2.5
@@ -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) {
@@ -866,6 +866,17 @@
rg_unlock(&lockp);
ret = group_migrate(svcName, target);
+
+ 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;
}
@@ -941,6 +952,13 @@
}
+int
+svc_status_inquiry(char *svcName)
+{
+ return group_op(svcName, RG_STATUS);
+}
+
+
/**
* Stop a cluster service.
*
--- cluster/rgmanager/src/daemons/rg_thread.c 2006/12/14 20:12:25 1.15.2.2
+++ cluster/rgmanager/src/daemons/rg_thread.c 2007/03/20 17:09:11 1.15.2.3
@@ -163,7 +163,7 @@
char myname[256];
resthread_t *myself;
request_t *req;
- uint32_t ret = RG_FAIL, error = 0;
+ int ret = RG_EFAIL, error = 0;
rg_inc_threads();
@@ -274,7 +274,7 @@
/*
* Bad news.
*/
- ret = RG_FAIL;
+ ret = RG_EFAIL;
}
break;
@@ -289,7 +289,7 @@
if (error == 0)
ret = RG_SUCCESS;
else
- ret = RG_FAIL;
+ ret = RG_EFAIL;
break;
case RG_CONDSTOP:
@@ -321,7 +321,7 @@
/*
* Bad news.
*/
- ret = RG_FAIL;
+ ret = RG_EFAIL;
}
break;
@@ -340,7 +340,7 @@
/*
* Bad news.
*/
- ret = RG_FAIL;
+ ret = RG_EFAIL;
}
pthread_mutex_lock(&my_queue_mutex);
@@ -368,7 +368,7 @@
/*
* Bad news.
*/
- ret = RG_FAIL;
+ ret = RG_EFAIL;
}
break;
@@ -393,7 +393,7 @@
/*
* Bad news.
*/
- ret = RG_FAIL;
+ ret = RG_EFAIL;
}
break;
--- cluster/rgmanager/src/daemons/test.c 2006/07/19 18:43:32 1.6
+++ cluster/rgmanager/src/daemons/test.c 2007/03/20 17:09:11 1.6.2.1
@@ -83,7 +83,7 @@
fod_t *domains = NULL;
resource_rule_t *rulelist = NULL, *currule;
resource_t *reslist = NULL, *curres;
- resource_node_t *tree = NULL;
+ resource_node_t *tree = NULL, *tmp, *rn = NULL;
int ccsfd, ret = 0, rules = 0;
fprintf(stderr,"Running in test mode.\n");
@@ -145,6 +145,13 @@
goto out;
}
+ list_do(&tree, tmp) {
+ if (tmp->rn_resource == curres) {
+ rn = tmp;
+ break;
+ }
+ } while (!list_done(&tree, tmp));
+
if (!strcmp(argv[1], "start")) {
printf("Starting %s...\n", argv[3]);
@@ -164,6 +171,23 @@
}
printf("Stop of %s complete\n", argv[3]);
goto out;
+ } else if (!strcmp(argv[1], "migrate")) {
+ printf("Migrating %s to %s...\n", argv[3], argv[4]);
+
+ #if 0
+ if (!group_migratory(curres)) {
+ printf("No can do\n");
+ ret = -1;
+ goto out;
+ }
+ #endif
+
+ if (res_exec(rn, "migrate", argv[4], 0)) {
+ ret = -1;
+ goto out;
+ }
+ printf("Migration of %s complete\n", argv[3]);
+ goto out;
} else if (!strcmp(argv[1], "status")) {
printf("Checking status of %s...\n", argv[3]);
--- cluster/rgmanager/src/resources/vm.sh 2006/10/23 22:47:01 1.1
+++ cluster/rgmanager/src/resources/vm.sh 2007/03/20 17:09:12 1.1.2.1
@@ -367,14 +367,15 @@
{
declare target=$1
- # XXX TODO
- return 1
+ xm migrate $OCF_RESKEY_name $target
+ return $?
}
#
# A Resource group is abstract, but the OCF RA API doesn't allow for abstract
# resources, so here it is.
#
+
case $1 in
start)
start
--- cluster/rgmanager/src/utils/Makefile 2006/07/19 18:44:58 1.13
+++ cluster/rgmanager/src/utils/Makefile 2007/03/20 17:09:12 1.13.2.1
@@ -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:12 1.4.2.1
@@ -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 2006/12/14 22:17:44 1.12.2.2
+++ cluster/rgmanager/src/utils/clusvcadm.c 2007/03/20 17:09:12 1.12.2.3
@@ -159,9 +159,9 @@
" 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 Xen VMs)\n");
+printf(" (e.g. for live migration of VMs)\n");
printf(" %s -q Quiet operation\n", name);
printf(" %s -R <group> Restart a group in place.\n",
name);
@@ -240,7 +240,7 @@
return 1;
}
- while ((opt = getopt(argc, argv, "lSue:d:r:n:m:vR:s:qh?")) != EOF) {
+ while ((opt = getopt(argc, argv, "lSue:M:d:r:n:m:vR:s:qh?")) != EOF) {
switch (opt) {
case 'l':
return do_lock();
@@ -265,13 +265,13 @@
break;
case 'r':
/* RELOCATE */
- actionstr = "trying to relocate";
+ actionstr = "relocate";
action = RG_RELOCATE;
svcname = optarg;
break;
case 'M':
/* MIGRATE */
- actionstr = "trying to migrate";
+ actionstr = "migrate";
action = RG_MIGRATE;
svcname = optarg;
break;
@@ -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);
@@ -359,9 +364,9 @@
msg_open(MSG_SOCKET, 0, RG_PORT, &ctx, 5);
} else {
if (!svctarget)
- printf("Trying to relocate %s", svcname);
+ printf("Trying to %s %s", actionstr, svcname);
else
- printf("Trying to relocate %s to %s", svcname,
+ printf("Trying to %s %s to %s", actionstr, svcname,
nodename);
printf("...");
fflush(stdout);
@@ -392,12 +397,13 @@
swab_SmMessageSt(&msg);
printf("%s\n", rg_strerror(msg.sm_data.d_ret));
-
if (msg.sm_data.d_ret == RG_ERUN)
return 0;
+ if (msg.sm_data.d_ret)
+ return msg.sm_data.d_ret;
switch (action) {
- case RG_MIGRATE:
+ /*case RG_MIGRATE:*/
case RG_RELOCATE:
case RG_START:
case RG_ENABLE:
next reply other threads:[~2007-03-20 17:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-20 17:09 lhh [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-03-20 17:10 [Cluster-devel] cluster/rgmanager include/members.h include/re lhh
2007-03-20 18:35 lhh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070320170914.27018.qmail@sourceware.org \
--to=lhh@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.