rgmanager: Add extra service status call (RHEL5)
PATCH 1/2 rgmanager: Add extra service status call (RHEL5)
Pass the flags and last transition time back to caller if the caller requests it with an additional parameter.
Resolves: rhbz#743214
--- rgmanager/src/daemons/slang_event.c | 105 +++++++++++++++++++++++++++++++++-- 1 files changed, 100 insertions(+), 5 deletions(-)
rgmanager/src/daemons/slang_event.c +100 -5
@@ -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),
Signature · 1 line
1.7.3.4
PATCH 2/2 rgmanager: Avoid duplicate restart of service (RHEL5)
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
--- rgmanager/src/resources/default_event_script.sl | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-)
rgmanager/src/resources/default_event_script.sl +18 -1
@@ -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]); }
Signature · 1 line
1.7.3.4
PATCH 2/2 rgmanager: Avoid duplicate restart of service (RHEL5)
rgmanager/src/resources/default_event_script.sl define default_service_event_handler() · line 522
Quoted 3 lines · Lon Hohberger
rgmanager/src/resources/default_event_script.sl +3
-0+ % 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