[pve-devel] [PATCH ha-manager 4/4] selcet_service_node: include all online nodes in default group
Thomas Lamprecht
t.lamprecht at proxmox.com
Tue May 3 10:03:17 CEST 2016
This changes the behaviour of selecting the node a service should
run on when try_next is true.
If no group is set all online nodes will be used as default group.
If the user sets a group this has no changes in behaviour.
If no group is set and the current_node is available and try_next
is false this has also no changes, it behaves the same as in the
past.
If we set try_next and the service has no group set this allows
a new node to be selected if possible. Fixes the relocation policy
on services with no group set, which else will never be relocated
to another group.
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
src/PVE/HA/Manager.pm | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm
index 9b29901..622ece8 100644
--- a/src/PVE/HA/Manager.pm
+++ b/src/PVE/HA/Manager.pm
@@ -54,8 +54,13 @@ sub flush_master_status {
sub select_service_node {
my ($groups, $online_node_usage, $service_conf, $current_node, $try_next) = @_;
- my $group = { 'nodes' => { $service_conf->{node} => 1 } }; # default group
+ my $group = {};
+ # add all online nodes to default group to allow try_next when no group set
+ foreach my $node (keys %$online_node_usage) {
+ $group->{nodes}->{$node} = 1;
+ }
+ # overwrite default if service is bound to a specific group
$group = $groups->{ids}->{$service_conf->{group}} if $service_conf->{group} &&
$groups->{ids}->{$service_conf->{group}};
@@ -85,7 +90,8 @@ sub select_service_node {
my @pri_list = sort {$b <=> $a} keys %$pri_groups;
return undef if !scalar(@pri_list);
-
+
+ # stay on current node if possible (avoids random migrations)
if (!$try_next && $group->{nofailback} && defined($group_members->{$current_node})) {
return $current_node;
}
--
2.1.4
More information about the pve-devel
mailing list