cluster: RHEL6 - rgmanager: Support convalesce w/ central_processing

Lon Hohberger lon at fedoraproject.org
Tue Feb 1 18:10:50 UTC 2011


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=3b03b46fe7d3c7d747db9a2b7721cc56aef458f2
Commit:        3b03b46fe7d3c7d747db9a2b7721cc56aef458f2
Parent:        c2fa8fe7c8f2a3cbf1023a170f3f78a8de559b7a
Author:        Lon Hohberger <lhh at redhat.com>
AuthorDate:    Thu Sep 9 10:58:17 2010 -0400
Committer:     Lon Hohberger <lhh at redhat.com>
CommitterDate: Tue Feb 1 12:32:31 2011 -0500

rgmanager: Support convalesce w/ central_processing

Resolves: rhbz#634277

Signed-off-by: Lon Hohberger <lhh at redhat.com>
---
 rgmanager/include/event.h                       |    1 +
 rgmanager/src/daemons/service_op.c              |   84 +++++++++++++++++++++++
 rgmanager/src/daemons/slang_event.c             |   18 +++++-
 rgmanager/src/resources/default_event_script.sl |    4 +
 4 files changed, 106 insertions(+), 1 deletions(-)

diff --git a/rgmanager/include/event.h b/rgmanager/include/event.h
index a9a8235..ad3fe39 100644
--- a/rgmanager/include/event.h
+++ b/rgmanager/include/event.h
@@ -124,6 +124,7 @@ void set_transition_throttling(int nsecs);
 int service_op_start(char *svcName, int *target_list, int target_list_len,
 		     int *new_owner);
 int service_op_stop(char *svcName, int do_disable, int event_type);
+int service_op_convalesce(const char *svcName);
 int service_op_migrate(char *svcName, int target_node);
 
 
diff --git a/rgmanager/src/daemons/service_op.c b/rgmanager/src/daemons/service_op.c
index 112b267..f094129 100644
--- a/rgmanager/src/daemons/service_op.c
+++ b/rgmanager/src/daemons/service_op.c
@@ -186,6 +186,90 @@ service_op_stop(char *svcName, int do_disable, int event_type)
 }
 
 
+int
+service_op_convalesce(const char *svcName)
+{
+	SmMessageSt msg;
+	int msg_ret;
+	msgctx_t ctx;
+	rg_state_t svcStatus;
+	int msgtarget = my_id();
+
+	/* Build the message header */
+	msg.sm_hdr.gh_magic = GENERIC_HDR_MAGIC;
+	msg.sm_hdr.gh_command = RG_ACTION_REQUEST;
+	msg.sm_hdr.gh_arg1 = RG_ACTION_MASTER; 
+	msg.sm_hdr.gh_length = sizeof (SmMessageSt);
+
+	msg.sm_data.d_action = RG_CONVALESCE;
+
+	strncpy(msg.sm_data.d_svcName, svcName,
+		sizeof(msg.sm_data.d_svcName));
+	msg.sm_data.d_ret = 0;
+	msg.sm_data.d_svcOwner = 0;
+
+	/* Open a connection to the local node - it will decide what to
+	   do in this case. XXX inefficient; should queue requests
+	   locally and immediately forward requests otherwise */
+
+	if (get_service_state_internal(svcName, &svcStatus) < 0)
+		return RG_EFAIL;
+	if (svcStatus.rs_owner > 0) {
+		if (member_online(svcStatus.rs_owner)) {
+			msgtarget = svcStatus.rs_owner;
+		} else {
+			/* If the owner is not online, 
+			   mark the service as 'stopped' but
+			   otherwise, do nothing.
+			 */
+			return svc_stop(svcName, RG_STOP);
+		}
+	}
+
+	if (msg_open(MSG_CLUSTER, msgtarget, RG_PORT, &ctx, 2 * cluster_timeout)< 0) {
+		logt_print(LOG_ERR,
+		       "#58: Failed opening connection to member #%d\n",
+		       my_id());
+		return -1;
+	}
+
+	/* Encode */
+	swab_SmMessageSt(&msg);
+
+	/* Send stop message to the other node */
+	if (msg_send(&ctx, &msg, sizeof (SmMessageSt)) < 
+	    (int)sizeof (SmMessageSt)) {
+		logt_print(LOG_ERR, "Failed to send complete message\n");
+		msg_close(&ctx);
+		return -1;
+	}
+
+	/* Check the response */
+	do {
+		msg_ret = msg_receive(&ctx, &msg,
+				      sizeof (SmMessageSt), 10);
+		if ((msg_ret == -1 && errno != ETIMEDOUT) ||
+		    (msg_ret > 0)) {
+			break;
+		}
+	} while(1);
+
+	if (msg_ret != sizeof (SmMessageSt)) {
+		logt_print(LOG_WARNING, "Strange response size: %d vs %d\n",
+		       msg_ret, (int)sizeof(SmMessageSt));
+		return 0;	/* XXX really UNKNOWN */
+	}
+
+	/* Got a valid response from other node. */
+	msg_close(&ctx);
+
+	/* Decode */
+	swab_SmMessageSt(&msg);
+
+	return msg.sm_data.d_ret;
+}
+
+
 /*
    service_op_migrate() - send a virtual machine to another host
    in the cluster
diff --git a/rgmanager/src/daemons/slang_event.c b/rgmanager/src/daemons/slang_event.c
index 55f0341..0b9f0d0 100644
--- a/rgmanager/src/daemons/slang_event.c
+++ b/rgmanager/src/daemons/slang_event.c
@@ -86,7 +86,8 @@ static int
    _user_restart = RG_RESTART,
    _user_migrate = RG_MIGRATE,
    _user_freeze = RG_FREEZE,
-   _user_unfreeze = RG_UNFREEZE;
+   _user_unfreeze = RG_UNFREEZE,
+   _user_convalesce = RG_CONVALESCE;
 
 
 SLang_Intrin_Var_Type rgmanager_vars[] =
@@ -139,6 +140,7 @@ SLang_Intrin_Var_Type rgmanager_vars[] =
 	MAKE_VARIABLE((char *)"USER_MIGRATE",	&_user_migrate,	SLANG_INT_TYPE, 1),
 	MAKE_VARIABLE((char *)"USER_FREEZE",	&_user_freeze,	SLANG_INT_TYPE, 1),
 	MAKE_VARIABLE((char *)"USER_UNFREEZE",	&_user_unfreeze,SLANG_INT_TYPE, 1),
+	MAKE_VARIABLE((char *)"USER_CONVALESCE",&_user_convalesce,SLANG_INT_TYPE, 1),
 
 	/* Errors */
 	MAKE_VARIABLE((char *)"rg_error",	&_rg_err,	SLANG_INT_TYPE, 1),
@@ -444,6 +446,18 @@ sl_service_property(char *svcName, char *prop)
 /**
   usage:
 
+  service_convalesce(name);
+ */
+static int
+sl_convalesce_service(const char *svcname)
+{
+	return service_op_convalesce(svcname);
+}
+
+
+/**
+  usage:
+
   stop_service(name, disable_flag);
  */
 static int
@@ -1034,6 +1048,8 @@ static SLang_Intrin_Fun_Type rgmanager_slang[] =
 			 SLANG_VOID_TYPE),
 	MAKE_INTRINSIC_0((char *)"service_stop", sl_stop_service,
 			 SLANG_INT_TYPE),
+	MAKE_INTRINSIC_S((char *)"service_convalesce", sl_convalesce_service,
+			 SLANG_INT_TYPE),
 	MAKE_INTRINSIC_0((char *)"service_start", sl_start_service,
 			 SLANG_INT_TYPE),
 	MAKE_INTRINSIC_0((char *)"service_migrate", sl_migrate_service,
diff --git a/rgmanager/src/resources/default_event_script.sl b/rgmanager/src/resources/default_event_script.sl
index fad22ac..4eae767 100644
--- a/rgmanager/src/resources/default_event_script.sl
+++ b/rgmanager/src/resources/default_event_script.sl
@@ -597,6 +597,10 @@ define default_user_event_handler()
 
 		ret = service_migrate(service_name, user_target);
 
+	} else if (user_request == USER_CONVALESCE) {
+
+		ret = service_convalesce(service_name);
+
 	}
 
 	return ret;


More information about the cluster-commits mailing list