Add the failback property in the HA resources config, which is functionally equivalent to the negation of the HA group's nofailback property. It will be used to migrate HA groups to HA node affinity rules.
The 'failback' flag is set to be enabled by default as the HA group's nofailback property was disabled by default. Signed-off-by: Daniel Kral <d.k...@proxmox.com> --- src/PVE/API2/HA/Resources.pm | 9 +++++++++ src/PVE/API2/HA/Status.pm | 11 ++++++++++- src/PVE/HA/Config.pm | 1 + src/PVE/HA/Resources.pm | 9 +++++++++ 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 + 8 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/PVE/API2/HA/Resources.pm b/src/PVE/API2/HA/Resources.pm index 5916204..e06d202 100644 --- a/src/PVE/API2/HA/Resources.pm +++ b/src/PVE/API2/HA/Resources.pm @@ -127,6 +127,15 @@ __PACKAGE__->register_method({ optional => 1, description => "Requested resource state.", }, + failback => { + description => "HA resource is automatically migrated to the" + . " node with the highest priority according to their node" + . " affinity rule, if a node with a higher priority than" + . " the current node comes online.", + type => 'boolean', + optional => 1, + default => 1, + }, group => get_standard_option('pve-ha-group-id', { optional => 1 }), max_restart => { description => "Maximal number of tries to restart the service on" diff --git a/src/PVE/API2/HA/Status.pm b/src/PVE/API2/HA/Status.pm index 1547e0e..4038766 100644 --- a/src/PVE/API2/HA/Status.pm +++ b/src/PVE/API2/HA/Status.pm @@ -109,6 +109,15 @@ __PACKAGE__->register_method({ type => "string", optional => 1, }, + failback => { + description => "HA resource is automatically migrated to" + . " the node with the highest priority according to their" + . " node affinity rule, if a node with a higher priority" + . " than the current node comes online.", + type => "boolean", + optional => 1, + default => 1, + }, max_relocate => { description => "For type 'service'.", type => "integer", @@ -260,7 +269,7 @@ __PACKAGE__->register_method({ # also return common resource attributes if (defined($sc)) { $data->{request_state} = $sc->{state}; - foreach my $key (qw(group max_restart max_relocate comment)) { + foreach my $key (qw(group max_restart max_relocate failback comment)) { $data->{$key} = $sc->{$key} if defined($sc->{$key}); } } diff --git a/src/PVE/HA/Config.pm b/src/PVE/HA/Config.pm index 2e520aa..7d071f3 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..b6d4a73 100644 --- a/src/PVE/HA/Resources.pm +++ b/src/PVE/HA/Resources.pm @@ -62,6 +62,15 @@ EODESC completion => \&PVE::HA::Tools::complete_group, }, ), + failback => { + description => "Automatically migrate HA resource to the node with" + . " the highest priority according to their node affinity " + . " 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 29b56c6..f6faa38 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 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel