* [Cluster-devel] [PATCH 1/2] rgmanager: Add extra service status call (RHEL5)
@ 2012-01-05 5:25 Lon Hohberger
2012-01-05 5:25 ` [Cluster-devel] [PATCH 2/2] rgmanager: Avoid duplicate restart of service (RHEL5) Lon Hohberger
0 siblings, 1 reply; 3+ messages in thread
From: Lon Hohberger @ 2012-01-05 5:25 UTC (permalink / raw)
To: cluster-devel.redhat.com
Pass the flags and last transition time back to caller
if the caller requests it with an additional parameter.
Resolves: rhbz#743214
Signed-off-by: Lon Hohberger <lhh@redhat.com>
---
rgmanager/src/daemons/slang_event.c | 105 +++++++++++++++++++++++++++++++++--
1 files changed, 100 insertions(+), 5 deletions(-)
diff --git a/rgmanager/src/daemons/slang_event.c b/rgmanager/src/daemons/slang_event.c
index 468706f..c9cca7a 100644
--- a/rgmanager/src/daemons/slang_event.c
+++ b/rgmanager/src/daemons/slang_event.c
@@ -30,6 +30,7 @@
#include <stdio.h>
#include <string.h>
+#define HAVE_LONG_LONG 1
#include <slang.h>
#include <sys/syslog.h>
#include <malloc.h>
@@ -229,14 +230,68 @@ get_service_state_internal(char *svcName, rg_state_t *svcStatus)
/*
- (restarts, last_owner, owner, state) = get_service_status(servicename)
+ (rte, restarts, last_owner, owner, state) =
+ service_status(servicename)
+
+For extra information (flags, transition time)
+ (transition_time, flags, rte, restarts, owner, state) =
+ service_status(servicename, 1);
*/
-void
-sl_service_status(char *svcName)
+static void
+sl_service_status(void)
{
+ char *svcName = NULL;
+ char *state_str;
rg_state_t svcStatus;
int restarts_exceeded = 0;
- char *state_str;
+ int nargs = 0, t = 0, extra = 0, flags = 0;
+ unsigned long long mtime;
+
+ nargs = SLang_Num_Function_Args;
+
+ /* Takes one or two args */
+ if (nargs <= 0 || nargs > 2) {
+ SLang_verror(SL_Syntax_Error,
+ (char *)"%s: Wrong # of args (%d), must be 1 or 2\n",
+ __FUNCTION__,
+ nargs);
+ return;
+ }
+
+ if (nargs == 2) {
+ t = SLang_peek_at_stack();
+ if (t != SLANG_INT_TYPE) {
+ SLang_verror(SL_Syntax_Error,
+ (char *)"%s: expected type %d got %d\n",
+ __FUNCTION__, SLANG_INT_TYPE, t);
+ return;
+ }
+
+ if (SLang_pop_integer(&extra) < 0) {
+ SLang_verror(SL_Syntax_Error,
+ (char *)"%s: Failed to pop integer from stack!\n",
+ __FUNCTION__);
+ return;
+ }
+ }
+
+ t = SLang_peek_at_stack();
+ if (t != SLANG_STRING_TYPE) {
+ SLang_verror(SL_Syntax_Error,
+ (char *)"%s: expected type %d got %d\n",
+ __FUNCTION__,
+ SLANG_STRING_TYPE, t);
+ return;
+ }
+
+ if (SLpop_string(&svcName) < 0) {
+ SLang_verror(SL_Syntax_Error,
+ (char *)"%s: Failed to pop string from stack!\n",
+ __FUNCTION__);
+ return;
+ }
+
+ /* Ok, got our parameters */
if (get_service_state_internal(svcName, &svcStatus) < 0) {
SLang_verror(SL_RunTime_Error,
@@ -246,6 +301,28 @@ sl_service_status(char *svcName)
return;
}
+ if (extra) {
+ /* push transition time and flags on to the stack */
+
+ mtime = (unsigned long long)svcStatus.rs_transition;
+ if (SLang_push_ulong_long(mtime) < 0) {
+ SLang_verror(SL_RunTime_Error,
+ (char *)"%s: Failed to push mtime %s",
+ __FUNCTION__,
+ svcName);
+ return;
+ }
+
+ flags = (int)svcStatus.rs_flags;
+ if (SLang_push_integer(flags) < 0) {
+ SLang_verror(SL_RunTime_Error,
+ (char *)"%s: Failed to push flags %s",
+ __FUNCTION__,
+ svcName);
+ return;
+ }
+ }
+
restarts_exceeded = check_restart(svcName);
if (SLang_push_integer(restarts_exceeded) < 0) {
SLang_verror(SL_RunTime_Error,
@@ -928,6 +1005,8 @@ array_to_string(char *buf, int buflen, int *array, int arraylen)
void
sl_clulog(int level)
{
+ unsigned long long s_ullval;
+ unsigned long s_ulval;
int t, nargs, len;
//int level;
int s_intval;
@@ -937,6 +1016,7 @@ sl_clulog(int level)
char tmp[256];
int need_free;
int remain = sizeof(logbuf)-2;
+ SLang_Any_Type *stuff = NULL;
nargs = SLang_Num_Function_Args;
if (nargs < 1)
@@ -960,6 +1040,16 @@ sl_clulog(int level)
}
free(nodes);
break;
+ case SLANG_ULONG_TYPE:
+ if (SLang_pop_ulong(&s_ulval) < 0)
+ return;
+ len=snprintf(tmp, sizeof(tmp) - 1, "%lu", s_ulval);
+ break;
+ case SLANG_ULLONG_TYPE:
+ if (SLang_pop_ulong_long(&s_ullval) < 0)
+ return;
+ len=snprintf(tmp, sizeof(tmp) - 1, "%llu", s_ullval);
+ break;
case SLANG_INT_TYPE:
if (SLang_pop_integer(&s_intval) < 0)
return;
@@ -976,6 +1066,11 @@ sl_clulog(int level)
need_free = 0;
len=snprintf(tmp, sizeof(tmp) - 1,
"{UnknownType %d}", t);
+ SLang_pop_anytype(&stuff);
+ if (stuff) {
+ SLang_free_anytype(stuff);
+ stuff = NULL;
+ }
break;
}
@@ -1075,7 +1170,7 @@ SLang_Intrin_Fun_Type rgmanager_slang[] =
MAKE_INTRINSIC_0("service_start", sl_start_service, SLANG_INT_TYPE),
MAKE_INTRINSIC_0((char *)"service_migrate", sl_migrate_service,
SLANG_INT_TYPE),
- MAKE_INTRINSIC_S("service_status", sl_service_status,
+ MAKE_INTRINSIC_0((char *)"service_status", sl_service_status,
SLANG_VOID_TYPE),
MAKE_INTRINSIC_S("service_freeze", sl_service_freeze,
SLANG_INT_TYPE),
--
1.7.3.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Cluster-devel] [PATCH 2/2] rgmanager: Avoid duplicate restart of service (RHEL5)
2012-01-05 5:25 [Cluster-devel] [PATCH 1/2] rgmanager: Add extra service status call (RHEL5) Lon Hohberger
@ 2012-01-05 5:25 ` Lon Hohberger
2012-01-05 14:09 ` Lon Hohberger
0 siblings, 1 reply; 3+ messages in thread
From: Lon Hohberger @ 2012-01-05 5:25 UTC (permalink / raw)
To: cluster-devel.redhat.com
If B depends on A and both A and B are running on
node 1 and node 1 fails, the stop events generated
will inadvertently cause B to be restarted after
the initial failover.
This patch resolves this issue by comparing the
start times in central_processing mode.
A known limitation to this patch is that in order
for this patch to work correctly, the cluster nodes'
time must be approximately in sync.
Resolves: rhbz#743214
Signed-off-by: Lon Hohberger <lhh@redhat.com>
---
rgmanager/src/resources/default_event_script.sl | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/rgmanager/src/resources/default_event_script.sl b/rgmanager/src/resources/default_event_script.sl
index cdde066..2d5503f 100644
--- a/rgmanager/src/resources/default_event_script.sl
+++ b/rgmanager/src/resources/default_event_script.sl
@@ -444,6 +444,8 @@ define default_service_event_handler()
variable tmp;
variable owner;
variable state;
+ variable d_trans, s_trans;
+ variable s_state;
debug("Executing default service event handler");
@@ -498,17 +500,32 @@ define default_service_event_handler()
continue;
}
- (,,, owner, state) = service_status(services[x]);
+ (d_trans,,,, owner, state) = service_status(services[x], 1);
if ((service_state == "started") and (owner < 0) and
(state == "stopped")) {
info("Dependency met; starting ", services[x]);
nodes = allowed_nodes(services[x]);
()=move_or_start(services[x], nodes);
+ continue;
}
% service died - stop service(s) that depend on the dead
if ((service_owner < 0) and (owner >= 0) and
(depend_mode != "soft")) {
+
+ % grab the -current- state of the service here
+ % If the service is running, and its dependent service
+ % as above is running and the dependent service was
+ % started at or after the service, then stopping it
+ % will result in unwanted service outage.
+ (s_trans,,,, s_state) = service_status(service_name);
+ if ((s_state == "started") and (state == "started") and
+ (d_trans >= s_trans)) {
+ debug("Skipping ", services[x],
+ "; restart not needed");
+ continue;
+ }
+
info("Dependency lost; stopping ", services[x]);
()=service_stop(services[x]);
}
--
1.7.3.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Cluster-devel] [PATCH 2/2] rgmanager: Avoid duplicate restart of service (RHEL5)
2012-01-05 5:25 ` [Cluster-devel] [PATCH 2/2] rgmanager: Avoid duplicate restart of service (RHEL5) Lon Hohberger
@ 2012-01-05 14:09 ` Lon Hohberger
0 siblings, 0 replies; 3+ messages in thread
From: Lon Hohberger @ 2012-01-05 14:09 UTC (permalink / raw)
To: cluster-devel.redhat.com
On 01/05/2012 12:25 AM, Lon Hohberger wrote:
> + % will result in unwanted service outage.
> + (s_trans,,,, s_state) = service_status(service_name);
> + if ((s_state == "started") and (state == "started") and
This is wrong - I am testing a fix.
-- Lon
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-01-05 14:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-05 5:25 [Cluster-devel] [PATCH 1/2] rgmanager: Add extra service status call (RHEL5) Lon Hohberger
2012-01-05 5:25 ` [Cluster-devel] [PATCH 2/2] rgmanager: Avoid duplicate restart of service (RHEL5) Lon Hohberger
2012-01-05 14:09 ` Lon Hohberger
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).