All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH] rhel5 rgmanager: Improve rgmanager's exclusive prioritization handling
@ 2011-04-07 13:46 Lon Hohberger
  2011-04-07 17:06 ` Fabio M. Di Nitto
  0 siblings, 1 reply; 2+ messages in thread
From: Lon Hohberger @ 2011-04-07 13:46 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Resolves: rhbz#680256

Signed-off-by: Lon Hohberger <lhh@redhat.com>
---
 rgmanager/src/resources/default_event_script.sl |   72 ++++++++++++++++++-----
 1 files changed, 56 insertions(+), 16 deletions(-)

diff --git a/rgmanager/src/resources/default_event_script.sl b/rgmanager/src/resources/default_event_script.sl
index db6e789..d567465 100644
--- a/rgmanager/src/resources/default_event_script.sl
+++ b/rgmanager/src/resources/default_event_script.sl
@@ -57,7 +57,7 @@ define separate_nodes(node_list)
 define exclusive_prioritize(svc, node_list)
 {
 	variable services = service_list();
-	variable len, x, y, owner, state, preferred_owner;
+	variable len, x, y, owner, nowner, state, preferred_owner;
 	variable svc_excl, other_excl;
 	variable nodes_x, nodes_s, nodes_e;
 
@@ -66,7 +66,8 @@ define exclusive_prioritize(svc, node_list)
 	%
 	svc_excl = atoi(service_property(svc, "exclusive"));
 	if (svc_excl == 0) {
-		return node_list;
+		notice("Starting ", svc, " on ", node_list);
+		return service_start(svc, node_list);
 	}
 
 	(nodes_e, nodes_s, nodes_x) = separate_nodes(node_list);
@@ -76,7 +77,11 @@ define exclusive_prioritize(svc, node_list)
 		% If we've got an exclusive service, only allow it to start on 
 		% empty nodes.
 		%
-		return nodes_e;
+		notice("Starting ", svc, " on ", nodes_e);
+		nowner = service_start(svc, nodes_e);
+		if ((nowner > 0) or (nowner != FAIL)) {
+			return nowner;
+		}
 	}
 
 	if (length(nodes_x) == 0) {
@@ -85,7 +90,7 @@ define exclusive_prioritize(svc, node_list)
 		% and no empty nodes, the service can not be started
 		%
 		notice("No empty / exclusive nodes available; cannot restart ", svc);
-		return nodes_x;
+		return ERR_DOMAIN;
 	}
 
 	%
@@ -129,14 +134,16 @@ define exclusive_prioritize(svc, node_list)
 		() = service_stop(services[x]);
 
 		%
-		% Return just the one node.
+		% Try just the one node.
 		%
-		node_list = subtract([0], 0);
-		node_list = union(node_list, owner);
-		return node_list;
+		notice("Starting ", svc, " on ", owner);
+		nowner = service_start(svc, owner);
+		if ((nowner > 0) or (nowner != FAIL)) {
+			return nowner;
+		}
 	}
 
-	return node_list;
+	return ERR_DOMAIN;
 }
 
 
@@ -200,13 +207,13 @@ define move_or_start(service, node_list)
 			return ERR_ABORT;
 		}
 	} else {
-		node_list = exclusive_prioritize(service, node_list);
-		notice("Starting ", service, " on ", node_list);
+		return exclusive_prioritize(service, node_list);
 	}
 
 	if (length(node_list) == 0) {
 		return ERR_DOMAIN; 
 	}
+	notice("Starting ", service, " on ", node_list);
 	return service_start(service, node_list);
 }
 
@@ -428,7 +435,7 @@ define default_node_event_handler()
 define default_service_event_handler()
 {
 	variable services = service_list();
-	variable x;
+	variable x, excl, len;
 	variable depends;
 	variable depend_mode;
 	variable policy;
@@ -472,15 +479,16 @@ define default_service_event_handler()
 		return;
 	}
 
-	for (x = 0; x < length(services); x++) {
+	%
+	% Simplistic dependency handling
+	%
+	len = length(services);
+	for (x = 0; x < len; x++) {
 		if (service_name == services[x]) {
 			% don't do anything to ourself! 
 			continue;
 		}
 
-		%
-		% Simplistic dependency handling
-		%
 		depends = service_property(services[x], "depend");
 		depend_mode = service_property(services[x], "depend_mode");
 
@@ -504,6 +512,38 @@ define default_service_event_handler()
 			()=service_stop(services[x]);
 		}
 	}
+
+	%
+	% Try to restart exclusive service which might have been recently
+	% stopped in order to make room for other exclusive services.
+	%
+	% Note that as a side effect, exclusive services (>=2) can't be
+	% stopped with clusvcadm -s; they will just pop right back - you
+	% must disable them if want them to stay stopped.
+	%
+	% This code has a side effect of brute-forcing the lowest-priority
+	% exclusive service offline in a cascaded fashion.
+	%
+	for (x = 0; x < len; x++) {
+		if (service_name == services[x]) {
+			% don't do anything to ourself!
+			continue;
+		}
+
+		excl = atoi(service_property(services[x], "exclusive"));
+		% non-exclusive or highest-prio (1) shouldn't get here
+		if ((excl == 0) or (excl == 1)) {
+			continue;
+		}
+
+		(,,, owner, state) = service_status(services[x]);
+		if (state == "stopped") {
+			info("Restarting stopped exclusive priority ",
+			     excl, " service ", services[x]);
+			nodes = allowed_nodes(services[x]);
+			()=move_or_start(services[x], nodes);
+		}
+	}
 }
 
 define default_config_event_handler()
-- 
1.7.3.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Cluster-devel] [PATCH] rhel5 rgmanager: Improve rgmanager's exclusive prioritization handling
  2011-04-07 13:46 [Cluster-devel] [PATCH] rhel5 rgmanager: Improve rgmanager's exclusive prioritization handling Lon Hohberger
@ 2011-04-07 17:06 ` Fabio M. Di Nitto
  0 siblings, 0 replies; 2+ messages in thread
From: Fabio M. Di Nitto @ 2011-04-07 17:06 UTC (permalink / raw)
  To: cluster-devel.redhat.com

ACK

On 04/07/2011 03:46 PM, Lon Hohberger wrote:
> Resolves: rhbz#680256
> 
> Signed-off-by: Lon Hohberger <lhh@redhat.com>
> ---
>  rgmanager/src/resources/default_event_script.sl |   72 ++++++++++++++++++-----
>  1 files changed, 56 insertions(+), 16 deletions(-)
> 
> diff --git a/rgmanager/src/resources/default_event_script.sl b/rgmanager/src/resources/default_event_script.sl
> index db6e789..d567465 100644
> --- a/rgmanager/src/resources/default_event_script.sl
> +++ b/rgmanager/src/resources/default_event_script.sl
> @@ -57,7 +57,7 @@ define separate_nodes(node_list)
>  define exclusive_prioritize(svc, node_list)
>  {
>  	variable services = service_list();
> -	variable len, x, y, owner, state, preferred_owner;
> +	variable len, x, y, owner, nowner, state, preferred_owner;
>  	variable svc_excl, other_excl;
>  	variable nodes_x, nodes_s, nodes_e;
>  
> @@ -66,7 +66,8 @@ define exclusive_prioritize(svc, node_list)
>  	%
>  	svc_excl = atoi(service_property(svc, "exclusive"));
>  	if (svc_excl == 0) {
> -		return node_list;
> +		notice("Starting ", svc, " on ", node_list);
> +		return service_start(svc, node_list);
>  	}
>  
>  	(nodes_e, nodes_s, nodes_x) = separate_nodes(node_list);
> @@ -76,7 +77,11 @@ define exclusive_prioritize(svc, node_list)
>  		% If we've got an exclusive service, only allow it to start on 
>  		% empty nodes.
>  		%
> -		return nodes_e;
> +		notice("Starting ", svc, " on ", nodes_e);
> +		nowner = service_start(svc, nodes_e);
> +		if ((nowner > 0) or (nowner != FAIL)) {
> +			return nowner;
> +		}
>  	}
>  
>  	if (length(nodes_x) == 0) {
> @@ -85,7 +90,7 @@ define exclusive_prioritize(svc, node_list)
>  		% and no empty nodes, the service can not be started
>  		%
>  		notice("No empty / exclusive nodes available; cannot restart ", svc);
> -		return nodes_x;
> +		return ERR_DOMAIN;
>  	}
>  
>  	%
> @@ -129,14 +134,16 @@ define exclusive_prioritize(svc, node_list)
>  		() = service_stop(services[x]);
>  
>  		%
> -		% Return just the one node.
> +		% Try just the one node.
>  		%
> -		node_list = subtract([0], 0);
> -		node_list = union(node_list, owner);
> -		return node_list;
> +		notice("Starting ", svc, " on ", owner);
> +		nowner = service_start(svc, owner);
> +		if ((nowner > 0) or (nowner != FAIL)) {
> +			return nowner;
> +		}
>  	}
>  
> -	return node_list;
> +	return ERR_DOMAIN;
>  }
>  
>  
> @@ -200,13 +207,13 @@ define move_or_start(service, node_list)
>  			return ERR_ABORT;
>  		}
>  	} else {
> -		node_list = exclusive_prioritize(service, node_list);
> -		notice("Starting ", service, " on ", node_list);
> +		return exclusive_prioritize(service, node_list);
>  	}
>  
>  	if (length(node_list) == 0) {
>  		return ERR_DOMAIN; 
>  	}
> +	notice("Starting ", service, " on ", node_list);
>  	return service_start(service, node_list);
>  }
>  
> @@ -428,7 +435,7 @@ define default_node_event_handler()
>  define default_service_event_handler()
>  {
>  	variable services = service_list();
> -	variable x;
> +	variable x, excl, len;
>  	variable depends;
>  	variable depend_mode;
>  	variable policy;
> @@ -472,15 +479,16 @@ define default_service_event_handler()
>  		return;
>  	}
>  
> -	for (x = 0; x < length(services); x++) {
> +	%
> +	% Simplistic dependency handling
> +	%
> +	len = length(services);
> +	for (x = 0; x < len; x++) {
>  		if (service_name == services[x]) {
>  			% don't do anything to ourself! 
>  			continue;
>  		}
>  
> -		%
> -		% Simplistic dependency handling
> -		%
>  		depends = service_property(services[x], "depend");
>  		depend_mode = service_property(services[x], "depend_mode");
>  
> @@ -504,6 +512,38 @@ define default_service_event_handler()
>  			()=service_stop(services[x]);
>  		}
>  	}
> +
> +	%
> +	% Try to restart exclusive service which might have been recently
> +	% stopped in order to make room for other exclusive services.
> +	%
> +	% Note that as a side effect, exclusive services (>=2) can't be
> +	% stopped with clusvcadm -s; they will just pop right back - you
> +	% must disable them if want them to stay stopped.
> +	%
> +	% This code has a side effect of brute-forcing the lowest-priority
> +	% exclusive service offline in a cascaded fashion.
> +	%
> +	for (x = 0; x < len; x++) {
> +		if (service_name == services[x]) {
> +			% don't do anything to ourself!
> +			continue;
> +		}
> +
> +		excl = atoi(service_property(services[x], "exclusive"));
> +		% non-exclusive or highest-prio (1) shouldn't get here
> +		if ((excl == 0) or (excl == 1)) {
> +			continue;
> +		}
> +
> +		(,,, owner, state) = service_status(services[x]);
> +		if (state == "stopped") {
> +			info("Restarting stopped exclusive priority ",
> +			     excl, " service ", services[x]);
> +			nodes = allowed_nodes(services[x]);
> +			()=move_or_start(services[x], nodes);
> +		}
> +	}
>  }
>  
>  define default_config_event_handler()



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-04-07 17:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-07 13:46 [Cluster-devel] [PATCH] rhel5 rgmanager: Improve rgmanager's exclusive prioritization handling Lon Hohberger
2011-04-07 17:06 ` Fabio M. Di Nitto

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.