From: "Michael Köppl" <m.koeppl@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH ha-manager 1/2] fix #6613: update rules containing the resource to be deleted
Date: Wed, 17 Sep 2025 13:53:10 +0200 [thread overview]
Message-ID: <20250917115316.131793-2-m.koeppl@proxmox.com> (raw)
In-Reply-To: <20250917115316.131793-1-m.koeppl@proxmox.com>
If the purge param is set, the resource that is deleted is also removed
from any rules referencing it. In the case that a resource is removed
that is also the last resource in a rule, the rule is also removed if
the purge option is enabled. This avoids rules remaining in the rules
config if their resources no longer exist.
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
src/PVE/HA/Config.pm | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/PVE/HA/Config.pm b/src/PVE/HA/Config.pm
index 301c62f..9a7ed0e 100644
--- a/src/PVE/HA/Config.pm
+++ b/src/PVE/HA/Config.pm
@@ -419,17 +419,30 @@ sub get_resource_motion_info {
# graceful, as long as locking + cfs_write works
sub delete_service_from_config {
- my ($sid) = @_;
+ my ($sid, $purge) = @_;
return 1 if !service_is_configured($sid);
my $res;
PVE::HA::Config::lock_ha_domain(
sub {
+
my $conf = read_resources_config();
$res = delete $conf->{ids}->{$sid};
write_resources_config($conf);
+ my $rules = read_rules_config();
+
+ if ($purge) {
+ for my $ruleid (keys $rules->{ids}->%*) {
+ my $rule_resources = $rules->{ids}->{$ruleid}->{resources} // {};
+
+ delete $rule_resources->{$sid};
+ delete $rules->{ids}->{$ruleid} if !%$rule_resources;
+ }
+ }
+
+ write_rules_config($rules);
},
"delete resource failed",
);
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-09-17 11:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-17 11:53 [pve-devel] [PATCH container/docs/ha-manager/manager/qemu-server 0/7] fix #6613: update HA rules upon resource deletion Michael Köppl
2025-09-17 11:53 ` Michael Köppl [this message]
2025-09-17 11:53 ` [pve-devel] [PATCH ha-manager 2/2] api: add purge parameter for " Michael Köppl
2025-09-17 11:53 ` [pve-devel] [PATCH qemu-server 1/1] fix #6613: pass purge param to delete_service_from_config Michael Köppl
2025-09-17 11:53 ` [pve-devel] [PATCH container " Michael Köppl
2025-09-17 11:53 ` [pve-devel] [PATCH manager 1/2] ui: add SafeDestroyResource window Michael Köppl
2025-09-17 11:53 ` [pve-devel] [PATCH manager 2/2] ui: use SafeDestroyResource window for removing resources Michael Köppl
2025-09-17 11:53 ` [pve-devel] [PATCH docs 1/1] add notes about effects of purge flag for resource and guest removal Michael Köppl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250917115316.131793-2-m.koeppl@proxmox.com \
--to=m.koeppl@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.