rgmanager: Add extra service status call (RHEL5)
PATCH 1/5 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/5 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 3/5 rgmanager: Fix call to service_status() (RHEL5)
In reply to Lon HohbergerThis patch simply fixes the calls to service_status(), the s_trans variable was being incorrectly set.
Resolves: rhbz#743214
--- rgmanager/src/resources/default_event_script.sl | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
rgmanager/src/resources/default_event_script.sl +5 -2
@@ -500,7 +500,7 @@ define default_service_event_handler() continue; } - (d_trans,,,, owner, state) = service_status(services[x], 1); + (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]);
@@ -518,9 +518,12 @@ define default_service_event_handler() % as above is running and the dependent service was % started@or after the service, then stopping it % will result in unwanted service outage. - (s_trans,,,, s_state) = service_status(service_name); + (s_trans,,,,,, s_state) = service_status(service_name, 1); if ((s_state == "started") and (state == "started") and (d_trans >= s_trans)) { + %debug("S:", service_name, " trans ", s_trans); + %debug("D:", services[x], " trans ", d_trans); + debug("Skipping ", services[x], "; restart not needed"); continue;
Signature · 1 line
1.7.3.4
PATCH 4/5 rgmanager: Fix tiny memory leak in sl_service_status (RHEL5)
In reply to Lon HohbergerResolves: rhbz#743214
--- rgmanager/src/daemons/slang_event.c | 23 ++++++++++++++--------- 1 files changed, 14 insertions(+), 9 deletions(-)
rgmanager/src/daemons/slang_event.c +14 -9
@@ -234,7 +234,8 @@ get_service_state_internal(char *svcName, rg_state_t *svcStatus)service_status(servicename) For extra information (flags, transition time) -(transition_time, flags, rte, restarts, owner, state) = +(transition_time, flags, rte, restarts, last_owner, +owner, state) = service_status(servicename, 1); */ static void
@@ -298,7 +299,7 @@ sl_service_status(void)"%s: Failed to get status for %s" , __FUNCTION__, svcName); -return ; + goto out_free; }if (extra) {
@@ -310,7 +311,7 @@ sl_service_status(void) (char *)"%s: Failed to push mtime %s" , __FUNCTION__, svcName); -return ; + goto out_free; } flags = (int )svcStatus.rs_flags;
@@ -319,7 +320,7 @@ sl_service_status(void) (char *)"%s: Failed to push flags %s" , __FUNCTION__, svcName); -return ; + goto out_free; } }
@@ -329,7 +330,7 @@ sl_service_status(void)"%s: Failed to push restarts_exceeded %s" , __FUNCTION__, svcName); -return ; + goto out_free; }if (SLang_push_integer (svcStatus.rs_restarts) <0 ) {
@@ -337,7 +338,7 @@ sl_service_status(void)"%s: Failed to push restarts for %s" , __FUNCTION__, svcName); -return ; + goto out_free; }if (SLang_push_integer (svcStatus.rs_last_owner) <0 ) {
@@ -345,7 +346,7 @@ sl_service_status(void)"%s: Failed to push last owner of %s" , __FUNCTION__, svcName); -return ; + goto out_free; }switch (svcStatus.rs_state) {
@@ -363,7 +364,7 @@ sl_service_status(void)"%s: Failed to push owner of %s" , __FUNCTION__, svcName); -return ; + goto out_free; }if (svcStatus.rs_flags &RG_FLAG_FROZEN ) {
@@ -379,7 +380,7 @@ sl_service_status(void)"%s: Failed to duplicate state of %s" , __FUNCTION__, svcName); -return ; + goto out_free; }if (SLang_push_malloced_string (state_str) <0 ) {
@@ -389,6 +390,10 @@ sl_service_status(void) svcName);free (state_str); } + +out_free: +if (svcName) +free (svcName); }
Signature · 1 line
1.7.3.4
PATCH 5/5 rgmanager: Fix dependency issue related to ordering (RHEL5)
In reply to Lon HohbergerIf you ordered two services the opposite way in cluster.conf ('b' first, which depends on 'a'), then rgmanager would fail over 'b' despite the fact that 'a' was not running yet - this is because the state of 'a' was not set to 'stopped' - so we need to check for a node-death event in move_or_start().
Resolves: rhbz#743214
--- rgmanager/src/resources/default_event_script.sl | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
rgmanager/src/resources/default_event_script.sl +5 -3
@@ -156,7 +156,9 @@ define move_or_start(service, node_list) depends = service_property(service, "depend"); if (depends != "") { (,,, owner, state) = service_status(depends); - if (owner < 0) { + if ((owner < 0) or + ((event_type == EVENT_NODE) and (owner == node_id) and + (node_state == 0))) { debug(service, " is not runnable; dependency not met"); ()=service_stop(service); return ERR_DEPEND;
@@ -521,8 +523,8 @@ define default_service_event_handler() (s_trans,,,,,, s_state) = service_status(service_name, 1); if ((s_state == "started") and (state == "started") and (d_trans >= s_trans)) { - %debug("S:", service_name, " trans ", s_trans); - %debug("D:", services[x], " trans ", d_trans); + debug("S:", service_name, " trans ", s_trans); + debug("D:", services[x], " trans ", d_trans); debug("Skipping ", services[x], "; restart not needed");
Signature · 1 line
1.7.3.4
PATCH 5/5 rgmanager: Fix dependency issue related to ordering (RHEL5)
rgmanager/src/resources/default_event_script.sl define default_service_event_handler() · line 530
Quoted 11 lines · Lon Hohberger
rgmanager/src/resources/default_event_script.sl +2
-2@@ -521,8 +523,8 @@ define default_service_event_handler() (s_trans,,,,,, s_state) = service_status(service_name, 1); if ((s_state == "started") and (state == "started") and (d_trans>= s_trans)) { - %debug("S:", service_name, " trans ", s_trans); - %debug("D:", services[x], " trans ", d_trans); + debug("S:", service_name, " trans ", s_trans); + debug("D:", services[x], " trans ", d_trans); debug("Skipping ", services[x], "; restart not needed");
Oops, the above won't be part of the patch set once merged.
-- Lon