public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH-SERIES ha-manager/manager v2 0/3] fix #7557: introduce 'auto-rebalance' property
@ 2026-05-13 10:46 Dominik Rusovac
  2026-05-13 10:46 ` [PATCH pve-manager v2 1/3] ui: ha: add auto-rebalance flag Dominik Rusovac
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dominik Rusovac @ 2026-05-13 10:46 UTC (permalink / raw)
  To: pve-devel

# TL;DR
Add 'auto-rebalance' property to HA resources config, which gives users
control over which HA resources may be moved by dynamic CRS during
automatic rebalancing.

# Details
The 'auto-rebalance' flag is set to true by default. As requested by [0],
disabling 'auto-rebalance' for some HA resource, say vm:100, means that vm:100
will be disregarded as a migration candidate during auto-rebalancing. Any HA
resource with a positive affinity for vm:100 will be disregarded too.

# Summary of Changes
This series:
- introduces property to control whether an HA resource may be migrated during
  automatic rebalancing;
- adds corresponding flag to PVE UI.

# Refs
[0] https://bugzilla.proxmox.com/show_bug.cgi?id=7557

NOTE: changes since v1 are given per patch in notes


pve-manager:

Dominik Rusovac (1):
  ui: ha: add auto-rebalance flag

 www/manager6/ha/ResourceEdit.js | 14 ++++++++++++++
 www/manager6/ha/Resources.js    |  6 ++++++
 www/manager6/ha/StatusView.js   |  4 ++++
 3 files changed, 24 insertions(+)


pve-ha-manager:

Dominik Rusovac (2):
  manager: set service config value in self
  fix #7557: introduce 'auto-rebalance' property

 src/PVE/API2/HA/Resources.pm      |   6 ++
 src/PVE/API2/HA/Status.pm         |  11 ++-
 src/PVE/HA/Config.pm              |   2 +
 src/PVE/HA/Manager.pm             |  38 ++++----
 src/PVE/HA/Resources.pm           |   6 ++
 src/PVE/HA/Resources/PVECT.pm     |   1 +
 src/PVE/HA/Resources/PVEVM.pm     |   1 +
 src/PVE/HA/Sim/Hardware.pm        |   1 +
 src/test/test_resource_bundles.pl | 142 ++++++++++++++++++++++++++++--
 9 files changed, 187 insertions(+), 21 deletions(-)


Summary over all repositories:
  12 files changed, 211 insertions(+), 21 deletions(-)

-- 
Generated by murpp 0.11.0




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH pve-manager v2 1/3] ui: ha: add auto-rebalance flag
  2026-05-13 10:46 [PATCH-SERIES ha-manager/manager v2 0/3] fix #7557: introduce 'auto-rebalance' property Dominik Rusovac
@ 2026-05-13 10:46 ` Dominik Rusovac
  2026-05-13 10:46 ` [PATCH pve-ha-manager v2 2/3] manager: set service config value in self Dominik Rusovac
  2026-05-13 12:05 ` [PATCH-SERIES ha-manager/manager v2 0/3] fix #7557: introduce 'auto-rebalance' property Daniel Kral
  2 siblings, 0 replies; 4+ messages in thread
From: Dominik Rusovac @ 2026-05-13 10:46 UTC (permalink / raw)
  To: pve-devel

Adapt the implementation of the 'failback' flag for the 'auto-rebalance'
flag, which controls whether an HA resource is allowed to migrate during
automatic rebalancing.

Signed-off-by: Dominik Rusovac <d.rusovac@proxmox.com>
---

Notes:
    no changes since v1

 www/manager6/ha/ResourceEdit.js | 14 ++++++++++++++
 www/manager6/ha/Resources.js    |  6 ++++++
 www/manager6/ha/StatusView.js   |  4 ++++
 3 files changed, 24 insertions(+)

diff --git a/www/manager6/ha/ResourceEdit.js b/www/manager6/ha/ResourceEdit.js
index a4f53dad..487d9cf3 100644
--- a/www/manager6/ha/ResourceEdit.js
+++ b/www/manager6/ha/ResourceEdit.js
@@ -12,6 +12,7 @@ Ext.define('PVE.ha.VMResourceInputPanel', {
         delete values.vmid;
 
         PVE.Utils.delete_if_default(values, 'failback', '1', me.isCreate);
+        PVE.Utils.delete_if_default(values, 'auto-rebalance', '1', me.isCreate);
         PVE.Utils.delete_if_default(values, 'max_restart', '1', me.isCreate);
         PVE.Utils.delete_if_default(values, 'max_relocate', '1', me.isCreate);
 
@@ -123,6 +124,19 @@ Ext.define('PVE.ha.VMResourceInputPanel', {
                 uncheckedValue: 0,
                 value: 1,
             },
+            {
+                xtype: 'proxmoxcheckbox',
+                name: 'auto-rebalance',
+                fieldLabel: gettext('Auto-Rebalance'),
+                autoEl: {
+                    tag: 'div',
+                    'data-qtip': gettext(
+                        'Enable if HA resource may be migrated during automatic rebalancing.',
+                    ),
+                },
+                uncheckedValue: 0,
+                value: 1,
+            },
             {
                 xtype: 'proxmoxKVComboBox',
                 name: 'state',
diff --git a/www/manager6/ha/Resources.js b/www/manager6/ha/Resources.js
index 621ed336..2fda3b24 100644
--- a/www/manager6/ha/Resources.js
+++ b/www/manager6/ha/Resources.js
@@ -150,6 +150,12 @@ Ext.define('PVE.ha.ResourcesView', {
                     sortable: true,
                     dataIndex: 'failback',
                 },
+                {
+                    header: gettext('Auto-Rebalance'),
+                    width: 100,
+                    sortable: true,
+                    dataIndex: 'auto-rebalance',
+                },
                 {
                     header: gettext('Description'),
                     flex: 1,
diff --git a/www/manager6/ha/StatusView.js b/www/manager6/ha/StatusView.js
index bc2da71f..59fcc6f3 100644
--- a/www/manager6/ha/StatusView.js
+++ b/www/manager6/ha/StatusView.js
@@ -84,6 +84,10 @@ Ext.define(
                     name: 'failback',
                     type: 'boolean',
                 },
+                {
+                    name: 'auto-rebalance',
+                    type: 'boolean',
+                },
                 'max_restart',
                 'max_relocate',
                 'type',
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH pve-ha-manager v2 2/3] manager: set service config value in self
  2026-05-13 10:46 [PATCH-SERIES ha-manager/manager v2 0/3] fix #7557: introduce 'auto-rebalance' property Dominik Rusovac
  2026-05-13 10:46 ` [PATCH pve-manager v2 1/3] ui: ha: add auto-rebalance flag Dominik Rusovac
@ 2026-05-13 10:46 ` Dominik Rusovac
  2026-05-13 12:05 ` [PATCH-SERIES ha-manager/manager v2 0/3] fix #7557: introduce 'auto-rebalance' property Daniel Kral
  2 siblings, 0 replies; 4+ messages in thread
From: Dominik Rusovac @ 2026-05-13 10:46 UTC (permalink / raw)
  To: pve-devel

This is in preparation for the follow-up patch.

Reading the value of 'auto-rebalance'-flag in the service config of an
HA resource is required to perform proper resource bundling.

Signed-off-by: Dominik Rusovac <d.rusovac@proxmox.com>
---

Notes:
    changes since v1:
    * replace close by 'foreach's with 'for'
    * declare and use $cd variable for the sake of DRY
    * adjust calls to use $self->{sc}
    * init empty $self->{sc} in constructor

 src/PVE/HA/Manager.pm | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm
index b69a6bb..ff2a756 100644
--- a/src/PVE/HA/Manager.pm
+++ b/src/PVE/HA/Manager.pm
@@ -82,6 +82,8 @@ sub new {
     # fixme: use separate class  PVE::HA::ServiceStatus
     $self->{ss} = $old_ms->{service_status} || {};
 
+    $self->{sc} = {};
+
     $self->{ms} = { master_node => $haenv->nodename() };
 
     # take over node request state to ensure a node in (manual) maintenance mode stays that way
@@ -1002,7 +1004,7 @@ sub manage {
 
     $self->try_persistent_group_migration();
 
-    my ($sc, $services_digest) = $haenv->read_service_config();
+    ($self->{sc}, my $services_digest) = $haenv->read_service_config();
 
     $self->{groups} = $haenv->read_group_config(); # update
 
@@ -1011,9 +1013,9 @@ sub manage {
     # skip service add/remove when disarmed - handle_disarm manages service status
     if (!$ms->{disarm}) {
         # add new service
-        foreach my $sid (sort keys %$sc) {
+        for my $sid (sort keys $self->{sc}->%*) {
             next if $ss->{$sid}; # already there
-            my $cd = $sc->{$sid};
+            my $cd = $self->{sc}->{$sid};
             next if $cd->{state} eq 'ignored';
 
             $haenv->log('info', "adding new service '$sid' on node '$cd->{node}'");
@@ -1027,10 +1029,11 @@ sub manage {
         }
 
         # remove stale or ignored services from manager state
-        foreach my $sid (keys %$ss) {
-            next if $sc->{$sid} && $sc->{$sid}->{state} ne 'ignored';
+        for my $sid (keys %$ss) {
+            my $cd = $self->{sc}->{$sid};
+            next if $cd && $cd->{state} ne 'ignored';
 
-            my $reason = defined($sc->{$sid}) ? 'ignored state requested' : 'no config';
+            my $reason = defined($cd) ? 'ignored state requested' : 'no config';
             $haenv->log('info', "removing stale service '$sid' ($reason)");
 
             # remove all service related state information
@@ -1043,7 +1046,7 @@ sub manage {
     my $new_rules = $haenv->read_rules_config();
 
     # TODO PVE 10: Remove group migration when HA groups have been fully migrated to rules
-    PVE::HA::Groups::migrate_groups_to_resources($self->{groups}, $sc);
+    PVE::HA::Groups::migrate_groups_to_resources($self->{groups}, $self->{sc});
 
     if (
         !$self->{compiled_rules}
@@ -1052,7 +1055,7 @@ sub manage {
         || $self->{groups}->{digest} ne $self->{last_groups_digest}
         || $services_digest && $services_digest ne $self->{last_services_digest}
     ) {
-        PVE::HA::Groups::migrate_groups_to_rules($new_rules, $self->{groups}, $sc);
+        PVE::HA::Groups::migrate_groups_to_rules($new_rules, $self->{groups}, $self->{sc});
 
         my $nodes = $self->{ns}->list_nodes();
         my $messages = PVE::HA::Rules->transform($new_rules, $nodes);
@@ -1088,7 +1091,7 @@ sub manage {
         foreach my $sid (sort keys %$ss) {
             next if $deferred_sids && !$deferred_sids->{$sid};
             my $sd = $ss->{$sid};
-            my $cd = $sc->{$sid} || { state => 'disabled' };
+            my $cd = $self->{sc}->{$sid} || { state => 'disabled' };
 
             my $lrm_res = $sd->{uid} ? $lrm_results->{ $sd->{uid} } : undef;
 
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH-SERIES ha-manager/manager v2 0/3] fix #7557: introduce 'auto-rebalance' property
  2026-05-13 10:46 [PATCH-SERIES ha-manager/manager v2 0/3] fix #7557: introduce 'auto-rebalance' property Dominik Rusovac
  2026-05-13 10:46 ` [PATCH pve-manager v2 1/3] ui: ha: add auto-rebalance flag Dominik Rusovac
  2026-05-13 10:46 ` [PATCH pve-ha-manager v2 2/3] manager: set service config value in self Dominik Rusovac
@ 2026-05-13 12:05 ` Daniel Kral
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Kral @ 2026-05-13 12:05 UTC (permalink / raw)
  To: Dominik Rusovac, pve-devel

On Wed May 13, 2026 at 12:46 PM CEST, Dominik Rusovac wrote:
> # TL;DR
> Add 'auto-rebalance' property to HA resources config, which gives users
> control over which HA resources may be moved by dynamic CRS during
> automatic rebalancing.
>
> # Details
> The 'auto-rebalance' flag is set to true by default. As requested by [0],
> disabling 'auto-rebalance' for some HA resource, say vm:100, means that vm:100
> will be disregarded as a migration candidate during auto-rebalancing. Any HA
> resource with a positive affinity for vm:100 will be disregarded too.
>
> # Summary of Changes
> This series:
> - introduces property to control whether an HA resource may be migrated during
>   automatic rebalancing;
> - adds corresponding flag to PVE UI.
>
> # Refs
> [0] https://bugzilla.proxmox.com/show_bug.cgi?id=7557
>
> NOTE: changes since v1 are given per patch in notes

Thanks for the quick v2, works as expected (tested the same as in the
previous review with some resource bundles clearing/setting
auto-rebalance for a bunch of HA resources)!

Consider the series as:

Reviewed-by: Daniel Kral <d.kral@proxmox.com>
Tested-by: Daniel Kral <d.kral@proxmox.com>




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-05-13 12:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-13 10:46 [PATCH-SERIES ha-manager/manager v2 0/3] fix #7557: introduce 'auto-rebalance' property Dominik Rusovac
2026-05-13 10:46 ` [PATCH pve-manager v2 1/3] ui: ha: add auto-rebalance flag Dominik Rusovac
2026-05-13 10:46 ` [PATCH pve-ha-manager v2 2/3] manager: set service config value in self Dominik Rusovac
2026-05-13 12:05 ` [PATCH-SERIES ha-manager/manager v2 0/3] fix #7557: introduce 'auto-rebalance' property Daniel Kral

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal