[pve-devel] [PATCH ha-manager 7/7] FenceConfig: assert that device priorities are unique

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Jul 14 14:41:53 CEST 2016


Each device priority must be unique to guarantee a deterministic
execution of the configured devices.
Else we cannot decide in which order we should write the devices to
the config file.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/HA/FenceConfig.pm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/PVE/HA/FenceConfig.pm b/src/PVE/HA/FenceConfig.pm
index fef480c..5d898d5 100644
--- a/src/PVE/HA/FenceConfig.pm
+++ b/src/PVE/HA/FenceConfig.pm
@@ -90,9 +90,16 @@ sub write_config {
 
     my $raw = '';
 
+    my $prev_priority = -1;
+
     foreach my $dev_name (sort {$data->{$a}->{priority} <=> $data->{$b}->{priority}} keys %$data) {
 	my $d = $data->{$dev_name};
 
+	die "Device '$dev_name' reuses priority! Priorities must be unique\n"
+	  if $prev_priority == $d->{priority};
+
+	$prev_priority = $d->{priority};
+
 	foreach my $sub_dev_nr (sort keys %{$d->{sub_devs}}) {
 	    my $sub_dev = $d->{sub_devs}->{$sub_dev_nr};
 	    my $dev_arg_str = PVE::Tools::cmd2string($sub_dev->{args});
-- 
2.1.4





More information about the pve-devel mailing list