[pve-devel] [PATCH ha-manager v2 10/26] resources: introduce failback property in service config

Daniel Kral d.kral at proxmox.com
Fri Jun 20 16:31:22 CEST 2025


Add the failback property in the service config, which is functionally
equivalent to the negation of the HA group's nofailback property.

It is set to be enabled by default as the HA group's nofailback property
was disabled by default.

Signed-off-by: Daniel Kral <d.kral at proxmox.com>
---
changes since v1:
    - NEW!

 src/PVE/HA/Config.pm          | 1 +
 src/PVE/HA/Resources.pm       | 8 ++++++++
 src/PVE/HA/Resources/PVECT.pm | 1 +
 src/PVE/HA/Resources/PVEVM.pm | 1 +
 src/PVE/HA/Sim/Hardware.pm    | 1 +
 src/test/test_failover1.pl    | 1 +
 6 files changed, 13 insertions(+)

diff --git a/src/PVE/HA/Config.pm b/src/PVE/HA/Config.pm
index 012ae16..1b67443 100644
--- a/src/PVE/HA/Config.pm
+++ b/src/PVE/HA/Config.pm
@@ -116,6 +116,7 @@ sub read_and_check_resources_config {
         my (undef, undef, $name) = parse_sid($sid);
         $d->{state} = 'started' if !defined($d->{state});
         $d->{state} = 'started' if $d->{state} eq 'enabled'; # backward compatibility
+        $d->{failback} = 1 if !defined($d->{failback});
         $d->{max_restart} = 1 if !defined($d->{max_restart});
         $d->{max_relocate} = 1 if !defined($d->{max_relocate});
         if (PVE::HA::Resources->lookup($d->{type})) {
diff --git a/src/PVE/HA/Resources.pm b/src/PVE/HA/Resources.pm
index 873387e..90410a9 100644
--- a/src/PVE/HA/Resources.pm
+++ b/src/PVE/HA/Resources.pm
@@ -62,6 +62,14 @@ EODESC
                 completion => \&PVE::HA::Tools::complete_group,
             },
         ),
+        failback => {
+            description => "Automatically migrate service to the node with the highest priority"
+                . " according to their location rules, if a node with a higher priority than the"
+                . " current node comes online.",
+            type => 'boolean',
+            optional => 1,
+            default => 1,
+        },
         max_restart => {
             description => "Maximal number of tries to restart the service on"
                 . " a node after its start failed.",
diff --git a/src/PVE/HA/Resources/PVECT.pm b/src/PVE/HA/Resources/PVECT.pm
index d1ab679..44644d9 100644
--- a/src/PVE/HA/Resources/PVECT.pm
+++ b/src/PVE/HA/Resources/PVECT.pm
@@ -37,6 +37,7 @@ sub options {
         state => { optional => 1 },
         group => { optional => 1 },
         comment => { optional => 1 },
+        failback => { optional => 1 },
         max_restart => { optional => 1 },
         max_relocate => { optional => 1 },
     };
diff --git a/src/PVE/HA/Resources/PVEVM.pm b/src/PVE/HA/Resources/PVEVM.pm
index fe65577..e634fe3 100644
--- a/src/PVE/HA/Resources/PVEVM.pm
+++ b/src/PVE/HA/Resources/PVEVM.pm
@@ -37,6 +37,7 @@ sub options {
         state => { optional => 1 },
         group => { optional => 1 },
         comment => { optional => 1 },
+        failback => { optional => 1 },
         max_restart => { optional => 1 },
         max_relocate => { optional => 1 },
     };
diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm
index 89dbdfa..579be2a 100644
--- a/src/PVE/HA/Sim/Hardware.pm
+++ b/src/PVE/HA/Sim/Hardware.pm
@@ -106,6 +106,7 @@ sub read_service_config {
         }
         $d->{state} = 'disabled' if !$d->{state};
         $d->{state} = 'started' if $d->{state} eq 'enabled'; # backward compatibility
+        $d->{failback} = 1 if !defined($d->{failback});
         $d->{max_restart} = 1 if !defined($d->{max_restart});
         $d->{max_relocate} = 1 if !defined($d->{max_relocate});
     }
diff --git a/src/test/test_failover1.pl b/src/test/test_failover1.pl
index 90f5cf4..90bd61a 100755
--- a/src/test/test_failover1.pl
+++ b/src/test/test_failover1.pl
@@ -22,6 +22,7 @@ $online_node_usage->add_node("node3");
 my $service_conf = {
     node => 'node1',
     group => 'prefer_node1',
+    failback => 1,
 };
 
 my $sd = {
-- 
2.39.5





More information about the pve-devel mailing list