[pve-devel] [PATCH ha-manager v2 2/7] Manager, LRM: sort service keys for deterministic tests

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Jun 15 17:58:58 CEST 2016


Else we the regression test produce a indeterministic output.
As the hashs would else be traversed in random order it makes no
real difference for the PVE2 environment, so just sort keys when we
add them to the cluster or spawn resource agent workers to avoid
that problem.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---

 src/PVE/HA/LRM.pm     | 2 +-
 src/PVE/HA/Manager.pm | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/PVE/HA/LRM.pm b/src/PVE/HA/LRM.pm
index a49410f..26c5c89 100644
--- a/src/PVE/HA/LRM.pm
+++ b/src/PVE/HA/LRM.pm
@@ -376,7 +376,7 @@ sub run_workers {
     while (($haenv->get_time() - $starttime) < 5) {
 	my $count =  $self->check_active_workers();
 
-	foreach my $sid (keys %{$self->{workers}}) {
+	foreach my $sid (sort keys %{$self->{workers}}) {
 	    last if $count >= $max_workers && $max_workers > 0;
 
 	    my $w = $self->{workers}->{$sid};
diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm
index 622ece8..1208720 100644
--- a/src/PVE/HA/Manager.pm
+++ b/src/PVE/HA/Manager.pm
@@ -360,7 +360,7 @@ sub manage {
 	
 	$self->recompute_online_node_usage();
 
-	foreach my $sid (keys %$ss) {
+	foreach my $sid (sort keys %$ss) {
 	    my $sd = $ss->{$sid};
 	    my $cd = $sc->{$sid} || { state => 'disabled' };
 
-- 
2.1.4





More information about the pve-devel mailing list