Skip to contentSkip to conversation

rgmanager: Mark services on dead nodes as stopped [RHEL5]

PATCH New Lon Hohberger 2 participants 3 messages Oct 27, 2011 – Oct 28, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 rgmanager: Mark services on dead nodes as stopped [RHEL5]

Cleans up clustat reporting and avoids a race.

Resolves: rhbz#722230

---
 rgmanager/src/daemons/groups.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
rgmanager/src/daemons/groups.c +26 -0
index 1e93e03..77f0d05 100644
@@ -741,6 +741,32 @@ eval_groups(int local, uint32_t nodeid, int nodeStatus)
 			continue;
 		}
 
+		/* Mark the service as stopped if applicable */
+		if ((svcStatus.rs_owner == nodeid && !nodeStatus) &&
+		    (svcStatus.rs_state == RG_STATE_STARTED ||
+		     svcStatus.rs_state == RG_STATE_RECOVER ||
+		     svcStatus.rs_state == RG_STATE_STARTING ||
+		     svcStatus.rs_state == RG_STATE_STOPPING )) {
+
+			clulog(LOG_DEBUG,
+			       "Marking %s on down member %d as stopped",
+			       svcName, nodeid);
+
+			svcStatus.rs_last_owner = svcStatus.rs_owner;
+			svcStatus.rs_state = RG_STATE_STOPPED;
+			svcStatus.rs_owner = 0;
+			svcStatus.rs_transition = (uint64_t)time(NULL);
+			svcStatus.rs_flags = 0;
+
+			if (set_rg_state(svcName, &svcStatus) != 0) {
+				clulog(LOG_ERR, "Failed to update state"
+				       " of %s during recovery; cannot "
+				       "fail over", svcName);
+				rg_unlock(&lockp);
+				continue;
+			}
+		}
+
 		rg_unlock(&lockp);
 
 		if (svcStatus.rs_owner == 0)
Signature · 1 line
1.7.3.4
#1 lore raw

PATCH 2/2 rgmanager: Send events on service stop & preserve frozen flag [RHEL5]

The rgmanger FROZEN flag is supposed to persist until disabled explicitly by an administrator or loss of quorum.

Resolves: rhbz#722230

---
 rgmanager/include/event.h        |    1 +
 rgmanager/src/daemons/groups.c   |   15 +++++++++++++--
 rgmanager/src/daemons/rg_state.c |    3 ++-
 3 files changed, 16 insertions(+), 3 deletions(-)
rgmanager/include/event.h +1 -0
index e63dffd..4a1714f 100644
@@ -137,6 +137,7 @@ int slang_process_event(event_table_t *event_table, event_t *ev);
 /* For distributed events. */
 void set_transition_throttling(int nsecs);
 int get_transition_throttling(void);
+void broadcast_event(char *svcName, uint32_t state, int owner, int last);
 
 /* Simplified service start. */
 int service_op_start(char *svcName, int *target_list, int target_list_len,
rgmanager/src/daemons/groups.c +13 -2
index 77f0d05..20ed2e1 100644
@@ -701,7 +701,7 @@ eval_groups(int local, uint32_t nodeid, int nodeStatus)
 	resource_node_t *node;
 	rg_state_t svcStatus;
 	cluster_member_list_t *membership;
-	int ret;
+	int ret, state_updated = 0;
 
 	if (rg_locked()) {
 		clulog(LOG_DEBUG,
@@ -718,6 +718,7 @@ eval_groups(int local, uint32_t nodeid, int nodeStatus)
 
 	list_do(&_tree, node) {
 
+		state_updated = 0;
 		res_build_name(svcName, sizeof(svcName), node->rn_resource);
 
 		/*
@@ -756,7 +757,9 @@ eval_groups(int local, uint32_t nodeid, int nodeStatus)
 			svcStatus.rs_state = RG_STATE_STOPPED;
 			svcStatus.rs_owner = 0;
 			svcStatus.rs_transition = (uint64_t)time(NULL);
-			svcStatus.rs_flags = 0;
+			/* If host fails, we need to remember
+			 * frozen flag */
+			svcStatus.rs_flags &= RG_FLAG_FROZEN;
 
 			if (set_rg_state(svcName, &svcStatus) != 0) {
 				clulog(LOG_ERR, "Failed to update state"
@@ -765,10 +768,18 @@ eval_groups(int local, uint32_t nodeid, int nodeStatus)
 				rg_unlock(&lockp);
 				continue;
 			}
+
+			state_updated = 1;
 		}
 
 		rg_unlock(&lockp);
 
+		if (state_updated) {
+			/* don't do this with lock held */
+			broadcast_event(svcName, RG_STATE_STOPPED, -1,
+					svcStatus.rs_last_owner);
+		}
+
 		if (svcStatus.rs_owner == 0)
 			nodeName = "none";
 		else
rgmanager/src/daemons/rg_state.c +2 -1
index c02bfda..a8b1e36 100644
@@ -1549,7 +1549,8 @@ _svc_stop_finish(char *svcName, int failed, uint32_t newstate)
 	}
 
 	svcStatus.rs_state = newstate;
-	svcStatus.rs_flags = 0;
+	/* If host fails, we need to remember frozen flag */
+	svcStatus.rs_flags &= RG_FLAG_FROZEN;
 
 	clulog(LOG_NOTICE, "Service %s is %s\n", svcName,
 	       rg_state_str(svcStatus.rs_state));
Signature · 1 line
1.7.3.4
#2 lore raw

PATCH 2/2 rgmanager: Send events on service stop & preserve frozen flag [RHEL5]

ACK both patches.

Fabio

Quoted 89 lines · Lon Hohberger

The rgmanger FROZEN flag is supposed to persist until disabled explicitly by an administrator or loss of quorum.

Resolves: rhbz#722230

---
 rgmanager/include/event.h        |    1 +
 rgmanager/src/daemons/groups.c   |   15 +++++++++++++--
 rgmanager/src/daemons/rg_state.c |    3 ++-
 3 files changed, 16 insertions(+), 3 deletions(-)
rgmanager/include/event.h +1 -0
index e63dffd..4a1714f 100644
@@ -137,6 +137,7 @@ int slang_process_event(event_table_t *event_table, event_t *ev);
 /* For distributed events. */
 void set_transition_throttling(int nsecs);
 int get_transition_throttling(void);
+void broadcast_event(char *svcName, uint32_t state, int owner, int last);
 
 /* Simplified service start. */
 int service_op_start(char *svcName, int *target_list, int target_list_len,
rgmanager/src/daemons/groups.c +13 -2
index 77f0d05..20ed2e1 100644
@@ -701,7 +701,7 @@ eval_groups(int local, uint32_t nodeid, int nodeStatus)
 	resource_node_t *node;
 	rg_state_t svcStatus;
 	cluster_member_list_t *membership;
-	int ret;
+	int ret, state_updated = 0;
 
 	if (rg_locked()) {
 		clulog(LOG_DEBUG,
@@ -718,6 +718,7 @@ eval_groups(int local, uint32_t nodeid, int nodeStatus)
 
 	list_do(&_tree, node) {
 
+		state_updated = 0;
 		res_build_name(svcName, sizeof(svcName), node->rn_resource);
 
 		/*
@@ -756,7 +757,9 @@ eval_groups(int local, uint32_t nodeid, int nodeStatus)
 			svcStatus.rs_state = RG_STATE_STOPPED;
 			svcStatus.rs_owner = 0;
 			svcStatus.rs_transition = (uint64_t)time(NULL);
-			svcStatus.rs_flags = 0;
+			/* If host fails, we need to remember
+			 * frozen flag */
+			svcStatus.rs_flags &= RG_FLAG_FROZEN;
 
 			if (set_rg_state(svcName, &svcStatus) != 0) {
 				clulog(LOG_ERR, "Failed to update state"
@@ -765,10 +768,18 @@ eval_groups(int local, uint32_t nodeid, int nodeStatus)
 				rg_unlock(&lockp);
 				continue;
 			}
+
+			state_updated = 1;
 		}
 
 		rg_unlock(&lockp);
 
+		if (state_updated) {
+			/* don't do this with lock held */
+			broadcast_event(svcName, RG_STATE_STOPPED, -1,
+					svcStatus.rs_last_owner);
+		}
+
 		if (svcStatus.rs_owner == 0)
 			nodeName = "none";
 		else
rgmanager/src/daemons/rg_state.c +2 -1
index c02bfda..a8b1e36 100644
@@ -1549,7 +1549,8 @@ _svc_stop_finish(char *svcName, int failed, uint32_t newstate)
 	}
 
 	svcStatus.rs_state = newstate;
-	svcStatus.rs_flags = 0;
+	/* If host fails, we need to remember frozen flag */
+	svcStatus.rs_flags &= RG_FLAG_FROZEN;
 
 	clulog(LOG_NOTICE, "Service %s is %s\n", svcName,
 	       rg_state_str(svcStatus.rs_state));