From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 6CDD31FF0BC for ; Thu, 15 Oct 2026 14:52:51 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 2A18B2178B; Thu, 15 Oct 2026 14:51:34 +0200 (CEST) From: Fiona Ebner To: pve-devel@lists.proxmox.com Subject: [PATCH ha-manager v4 12/27] queue resource motion: support migration options Date: Thu, 15 Oct 2026 14:50:46 +0200 Message-ID: <20261015125112.174954-13-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261015125112.174954-1-f.ebner@proxmox.com> References: <20261015125112.174954-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1792068676845 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.412 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 5HK54MQYATFHLA4XDW4VTOLW2LW4Z3MM X-Message-ID-Hash: 5HK54MQYATFHLA4XDW4VTOLW2LW4Z3MM X-MailFrom: f.ebner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: For dependent resource, it is necessary to filter out migration properties that are not applicable to the resource's type. Signed-off-by: Fiona Ebner --- Changes in v4: * Apply filtered migration options to resource of different type. src/PVE/HA/Manager.pm | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm index 9fca61a..c28d7fa 100644 --- a/src/PVE/HA/Manager.pm +++ b/src/PVE/HA/Manager.pm @@ -295,7 +295,7 @@ sub load_balance { ); $haenv->log('info', "auto rebalance - $task $sid to $target ($imbalance_change_str)"); - $self->queue_resource_motion($cmd, $task, $sid, $target); + $self->queue_resource_motion($cmd, $task, $sid, $target, {}); } sub cleanup { @@ -610,7 +610,7 @@ sub read_lrm_status { } sub queue_resource_motion { - my ($self, $cmd, $task, $sid, $target) = @_; + my ($self, $cmd, $task, $sid, $target, $migrate_options) = @_; my ($haenv, $sc, $ss, $ns, $compiled_rules) = $self->@{qw(haenv sc ss ns compiled_rules)}; my $online_nodes = { map { $_ => 1 } $self->{ns}->list_online_nodes()->@* }; @@ -641,18 +641,40 @@ sub queue_resource_motion { } $haenv->log('info', "got crm command: $cmd"); - $ss->{$sid}->{cmd} = [$task, $target]; + $ss->{$sid}->{cmd} = [$task, $target, $migrate_options]; + + # For dependent resources of a different type, filter unapplicable options. + my $_migrate_options_for_type = {}; + my $migrate_options_for_type = sub { + my ($type) = @_; + return $_migrate_options_for_type->{$type} + if defined($_migrate_options_for_type->{$type}); + + my $plugin = PVE::HA::Resources->lookup($type); + my $applicable_properties = $plugin->migrate_json_properties(); + + $_migrate_options_for_type->{$type} = {}; + for my $key (keys $migrate_options->%*) { + next if !exists($applicable_properties->{$key}); + $_migrate_options_for_type->{$type}->{$key} = $migrate_options->{$key}; + } + + return $_migrate_options_for_type->{$type}; + }; for my $csid (@$dependent_resources) { next if $ss->{$csid}->{node} && $ss->{$csid}->{node} eq $target; next if $ss->{$csid}->{target} && $ss->{$csid}->{target} eq $target; + my $type = ($haenv->parse_sid($csid))[1]; + my $applicable_migrate_options = $migrate_options_for_type->($type); + $haenv->log( 'info', "crm command '$cmd' - $task service '$csid' to node '$target'" . " (service '$csid' in positive affinity with service '$sid')", ); - $ss->{$csid}->{cmd} = [$task, $target]; + $ss->{$csid}->{cmd} = [$task, $target, $applicable_migrate_options]; } } @@ -704,7 +726,7 @@ sub update_crm_commands { my ($task, $sid, $node) = ($1, $2, $3); if (my $sd = $ss->{$sid}) { if (check_resource_motion_valid($self, $node, $sd, "ignore crm command '$cmd'")) { - $self->queue_resource_motion($cmd, $task, $sid, $node); + $self->queue_resource_motion($cmd, $task, $sid, $node, {}); } } else { $haenv->log('err', "crm command error - no such service: $cmd"); -- 2.47.3