* [Cluster-devel] [PATCH 1/5] rgmanager: Add extra service status call (RHEL5)
@ 2012-01-05 15:57 Lon Hohberger
2012-01-05 15:57 ` [Cluster-devel] [PATCH 2/5] rgmanager: Avoid duplicate restart of service (RHEL5) Lon Hohberger
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Lon Hohberger @ 2012-01-05 15:57 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] 6+ messages in thread
* [Cluster-devel] [PATCH 2/5] rgmanager: Avoid duplicate restart of service (RHEL5)
2012-01-05 15:57 [Cluster-devel] [PATCH 1/5] rgmanager: Add extra service status call (RHEL5) Lon Hohberger
@ 2012-01-05 15:57 ` Lon Hohberger
2012-01-05 15:57 ` [Cluster-devel] [PATCH 3/5] rgmanager: Fix call to service_status() (RHEL5) Lon Hohberger
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Lon Hohberger @ 2012-01-05 15:57 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] 6+ messages in thread
* [Cluster-devel] [PATCH 3/5] rgmanager: Fix call to service_status() (RHEL5)
2012-01-05 15:57 [Cluster-devel] [PATCH 1/5] rgmanager: Add extra service status call (RHEL5) Lon Hohberger
2012-01-05 15:57 ` [Cluster-devel] [PATCH 2/5] rgmanager: Avoid duplicate restart of service (RHEL5) Lon Hohberger
@ 2012-01-05 15:57 ` Lon Hohberger
2012-01-05 15:57 ` [Cluster-devel] [PATCH 4/5] rgmanager: Fix tiny memory leak in sl_service_status (RHEL5) Lon Hohberger
2012-01-05 15:57 ` [Cluster-devel] [PATCH 5/5] rgmanager: Fix dependency issue related to ordering (RHEL5) Lon Hohberger
3 siblings, 0 replies; 6+ messages in thread
From: Lon Hohberger @ 2012-01-05 15:57 UTC (permalink / raw)
To: cluster-devel.redhat.com
This patch simply fixes the calls to service_status(), the
s_trans variable was being incorrectly set.
Resolves: rhbz#743214
Signed-off-by: Lon Hohberger <lhh@redhat.com>
---
rgmanager/src/resources/default_event_script.sl | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/rgmanager/src/resources/default_event_script.sl b/rgmanager/src/resources/default_event_script.sl
index 2d5503f..f2c7bc1 100644
--- a/rgmanager/src/resources/default_event_script.sl
+++ b/rgmanager/src/resources/default_event_script.sl
@@ -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;
--
1.7.3.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Cluster-devel] [PATCH 4/5] rgmanager: Fix tiny memory leak in sl_service_status (RHEL5)
2012-01-05 15:57 [Cluster-devel] [PATCH 1/5] rgmanager: Add extra service status call (RHEL5) Lon Hohberger
2012-01-05 15:57 ` [Cluster-devel] [PATCH 2/5] rgmanager: Avoid duplicate restart of service (RHEL5) Lon Hohberger
2012-01-05 15:57 ` [Cluster-devel] [PATCH 3/5] rgmanager: Fix call to service_status() (RHEL5) Lon Hohberger
@ 2012-01-05 15:57 ` Lon Hohberger
2012-01-05 15:57 ` [Cluster-devel] [PATCH 5/5] rgmanager: Fix dependency issue related to ordering (RHEL5) Lon Hohberger
3 siblings, 0 replies; 6+ messages in thread
From: Lon Hohberger @ 2012-01-05 15:57 UTC (permalink / raw)
To: cluster-devel.redhat.com
Resolves: rhbz#743214
Signed-off-by: Lon Hohberger <lhh@redhat.com>
---
rgmanager/src/daemons/slang_event.c | 23 ++++++++++++++---------
1 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/rgmanager/src/daemons/slang_event.c b/rgmanager/src/daemons/slang_event.c
index c9cca7a..b033656 100644
--- a/rgmanager/src/daemons/slang_event.c
+++ b/rgmanager/src/daemons/slang_event.c
@@ -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);
}
--
1.7.3.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Cluster-devel] [PATCH 5/5] rgmanager: Fix dependency issue related to ordering (RHEL5)
2012-01-05 15:57 [Cluster-devel] [PATCH 1/5] rgmanager: Add extra service status call (RHEL5) Lon Hohberger
` (2 preceding siblings ...)
2012-01-05 15:57 ` [Cluster-devel] [PATCH 4/5] rgmanager: Fix tiny memory leak in sl_service_status (RHEL5) Lon Hohberger
@ 2012-01-05 15:57 ` Lon Hohberger
2012-01-05 16:34 ` Lon Hohberger
3 siblings, 1 reply; 6+ messages in thread
From: Lon Hohberger @ 2012-01-05 15:57 UTC (permalink / raw)
To: cluster-devel.redhat.com
If 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
Signed-off-by: Lon Hohberger <lhh@redhat.com>
---
rgmanager/src/resources/default_event_script.sl | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/rgmanager/src/resources/default_event_script.sl b/rgmanager/src/resources/default_event_script.sl
index f2c7bc1..be434e9 100644
--- a/rgmanager/src/resources/default_event_script.sl
+++ b/rgmanager/src/resources/default_event_script.sl
@@ -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");
--
1.7.3.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Cluster-devel] [PATCH 5/5] rgmanager: Fix dependency issue related to ordering (RHEL5)
2012-01-05 15:57 ` [Cluster-devel] [PATCH 5/5] rgmanager: Fix dependency issue related to ordering (RHEL5) Lon Hohberger
@ 2012-01-05 16:34 ` Lon Hohberger
0 siblings, 0 replies; 6+ messages in thread
From: Lon Hohberger @ 2012-01-05 16:34 UTC (permalink / raw)
To: cluster-devel.redhat.com
On 01/05/2012 10:57 AM, Lon Hohberger wrote:
> @@ -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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-01-05 16:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-05 15:57 [Cluster-devel] [PATCH 1/5] rgmanager: Add extra service status call (RHEL5) Lon Hohberger
2012-01-05 15:57 ` [Cluster-devel] [PATCH 2/5] rgmanager: Avoid duplicate restart of service (RHEL5) Lon Hohberger
2012-01-05 15:57 ` [Cluster-devel] [PATCH 3/5] rgmanager: Fix call to service_status() (RHEL5) Lon Hohberger
2012-01-05 15:57 ` [Cluster-devel] [PATCH 4/5] rgmanager: Fix tiny memory leak in sl_service_status (RHEL5) Lon Hohberger
2012-01-05 15:57 ` [Cluster-devel] [PATCH 5/5] rgmanager: Fix dependency issue related to ordering (RHEL5) Lon Hohberger
2012-01-05 16:34 ` 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).