From: Fiona Ebner <f.ebner@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
Daniel Kral <d.kral@proxmox.com>
Subject: Re: [pve-devel] [PATCH ha-manager 3/4] config, env: allow bulk updates with update_resources_config
Date: Mon, 19 Jan 2026 12:48:41 +0100 [thread overview]
Message-ID: <1aa14390-ebc4-44e8-874e-292354ad2468@proxmox.com> (raw)
In-Reply-To: <20251215102409.142350-4-d.kral@proxmox.com>
Am 15.12.25 um 11:24 AM schrieb Daniel Kral:
> diff --git a/src/PVE/HA/Config.pm b/src/PVE/HA/Config.pm
> index 04e039e0..159798a7 100644
> --- a/src/PVE/HA/Config.pm
> +++ b/src/PVE/HA/Config.pm
> @@ -136,37 +136,46 @@ sub read_and_check_resources_config {
> return wantarray ? ($conf, $res->{digest}) : $conf;
> }
>
> +my sub update_single_resource_config_inplace {
> + my ($cfg, $sid, $param, $delete) = @_;
> +
> + ($sid, my $type, my $name) = parse_sid($sid);
> +
> + my $scfg = $cfg->{ids}->{$sid}
> + || die "no such resource '$sid'\n";
> +
> + my $plugin = PVE::HA::Resources->lookup($scfg->{type});
> + my $opts = $plugin->check_config($sid, $param, 0, 1);
> +
> + foreach my $k (%$opts) {
> + $scfg->{$k} = $opts->{$k};
> + }
> +
> + if ($delete) {
> + my $options = $plugin->private()->{options}->{$ytype};
> + foreach my $k (PVE::Tools::split_list($delete)) {
> + my $d = $options->{$k}
> + || die "no such option '$k'\n";
> + die "unable to delete required option '$k'\n"
> + if !$d->{optional};
> + die "unable to delete fixed option '$k'\n"
> + if $d->{fixed};
> + delete $scfg->{$k};
> + }
> + }
> +}
> +
> sub update_resources_config {
> - my ($sid, $param, $delete, $digest) = @_;
> + my ($changes, $delete, $digest) = @_;
Nit: I feel like the $delete belongs inside the $changes for a clean
interface. So something like
$changes = {
$sid => {
param => $param,
delete => $delete,
}
}
I know the single caller using bulk won't need it, but the current
interface does feel slightly off to me. What do you think?
>
> lock_ha_domain(
> sub {
> my $cfg = read_resources_config();
> - ($sid, my $type, my $name) = parse_sid($sid);
> -
> PVE::SectionConfig::assert_if_modified($cfg, $digest);
>
> - my $scfg = $cfg->{ids}->{$sid}
> - || die "no such resource '$sid'\n";
> -
> - my $plugin = PVE::HA::Resources->lookup($scfg->{type});
> - my $opts = $plugin->check_config($sid, $param, 0, 1);
> -
> - foreach my $k (%$opts) {
> - $scfg->{$k} = $opts->{$k};
> - }
> -
> - if ($delete) {
> - my $options = $plugin->private()->{options}->{$type};
> - foreach my $k (PVE::Tools::split_list($delete)) {
> - my $d = $options->{$k}
> - || die "no such option '$k'\n";
> - die "unable to delete required option '$k'\n"
> - if !$d->{optional};
> - die "unable to delete fixed option '$k'\n"
> - if $d->{fixed};
> - delete $scfg->{$k};
> - }
> + for my $sid (keys %$changes) {
Nit: I'd prefer to iterate after 'sort'
> + my $param = $changes->{$sid};
> + update_single_resource_config_inplace($cfg, $sid, $param, $delete);
> }
>
> write_resources_config($cfg);
---snip---
> diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm
> index 0848d18a..b19a23b4 100644
> --- a/src/PVE/HA/Sim/Hardware.pm
> +++ b/src/PVE/HA/Sim/Hardware.pm
> @@ -114,10 +114,8 @@ sub read_service_config {
> return $conf;
> }
>
> -sub update_service_config {
> - my ($self, $sid, $param, $delete) = @_;
> -
> - my $conf = $self->read_service_config();
> +my sub update_single_service_config_inplace {
> + my ($conf, $sid, $param, $delete) = @_;
>
> my $sconf = $conf->{$sid} || die "no such resource '$sid'\n";
>
> @@ -130,6 +128,17 @@ sub update_service_config {
> delete $sconf->{$k};
> }
> }
> +}
> +
> +sub update_service_config {
> + my ($self, $changes, $delete) = @_;
> +
> + my $conf = $self->read_service_config();
> +
> + for my $sid (keys %$changes) {
Nit: I'd prefer to iterate after 'sort'
> + my $param = $changes->{$sid};
> + update_single_service_config_inplace($conf, $sid, $param, $delete);
> + }
>
> $self->write_service_config($conf);
> }
_______________________________________________
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:[~2026-01-19 11:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-15 10:18 [pve-devel] [PATCH ha-manager 0/4] fix #7133 and improve group migration Daniel Kral
2025-12-15 10:18 ` [pve-devel] [PATCH ha-manager 1/4] fix #7133: manager: group migration: skip update for resources without group Daniel Kral
2025-12-15 10:18 ` [pve-devel] [PATCH ha-manager 2/4] manager: group migration: write only non-default failback values Daniel Kral
2025-12-15 10:18 ` [pve-devel] [PATCH ha-manager 3/4] config, env: allow bulk updates with update_resources_config Daniel Kral
2026-01-19 11:48 ` Fiona Ebner [this message]
2026-01-19 12:20 ` Daniel Kral
2026-01-19 12:44 ` Fiona Ebner
2025-12-15 10:18 ` [pve-devel] [PATCH ha-manager 4/4] manager: group migration: bulk update changes to resource config Daniel Kral
2026-01-19 11:49 ` [pve-devel] [PATCH ha-manager 0/4] fix #7133 and improve group migration Fiona Ebner
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=1aa14390-ebc4-44e8-874e-292354ad2468@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=d.kral@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.