From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id ACF801FF0AF for ; Thu, 22 Oct 2026 11:26:58 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id C563921605; Thu, 22 Oct 2026 11:26:56 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 22 Oct 2026 11:26:52 +0200 Message-Id: Subject: Re: [PATCH proxmox-perl-rs 06/15] fix #7993: pve-rs: resource-scheduling: add weights to pve bindings From: "Daniel Kral" To: "Dominik Rusovac" , X-Mailer: aerc 0.22.0-10-g6373ac9d2179-dirty References: <20261021085932.1196302-1-d.rusovac@proxmox.com> <20261021085932.1196302-7-d.rusovac@proxmox.com> In-Reply-To: <20261021085932.1196302-7-d.rusovac@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1792661212478 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.748 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: LV4H3D7NGEBXSDLRO3UJEF3VN24BASTU X-Message-ID-Hash: LV4H3D7NGEBXSDLRO3UJEF3VN24BASTU X-MailFrom: d.kral@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: The same applies here as in the changes for proxmox_resource_scheduling, this would need a versioned break, e.g., if users have a newer libpve-rs but an older ha-manager, the HA Manager would fail calling these as the function signature was changed. Though here, we could probably add options structs at the end of the function parameter list instead of having extra weighted_ versions, e.g.: #[derive(Deserialize, Debug)] struct BruteforceOptions { #[serde(default =3D "1")] cpu_weight: usize, #[serde(default =3D "1")] mem_weight: usize, } #[export] pub fn score_best_balancing_migration_candidates( #[try_from_ref] this: &Scheduler, candidates: Vec, limit: usize, options: BruteforceOptions, ) -> Result, Error> {} AFAIK this shouldn't cause old pve-ha-manager versions failing to call this as there's a default value for each parameter. Could also be a struct with all fields being some Option and then doing the default thing in the function body itself. Haven't tested this yet though. On Wed Oct 21, 2026 at 10:59 AM CEST, Dominik Rusovac wrote: > Add weights for weighted load balancing. > > Adjust existing resource scheduling test to explicitly use same weights > as before. > > Signed-off-by: Dominik Rusovac > --- > .../resource_scheduling/pve_dynamic.rs | 27 +++++++++++++++---- > .../resource_scheduling/pve_static.rs | 25 +++++++++++++---- > pve-rs/test/resource_scheduling.pl | 3 ++- > 3 files changed, 44 insertions(+), 11 deletions(-) > > diff --git a/pve-rs/src/bindings/resource_scheduling/pve_dynamic.rs b/pve= -rs/src/bindings/resource_scheduling/pve_dynamic.rs > index 8e066e0..d6b6f9b 100644 > --- a/pve-rs/src/bindings/resource_scheduling/pve_dynamic.rs > +++ b/pve-rs/src/bindings/resource_scheduling/pve_dynamic.rs > @@ -166,10 +166,16 @@ pub mod pve_rs_resource_scheduling_dynamic { > /// > /// See [`proxmox_resource_scheduling::scheduler::Scheduler::node_im= balance`]. > #[export] > - pub fn calculate_node_imbalance(#[try_from_ref] this: &Scheduler) ->= f64 { > + pub fn calculate_node_imbalance( > + #[try_from_ref] this: &Scheduler, > + cpu_weight: usize, > + mem_weight: usize, > + ) -> f64 { > let usage =3D this.inner.lock().unwrap(); > =20 > - usage.to_scheduler::().node_imbalance() > + usage > + .to_scheduler::() > + .node_imbalance(cpu_weight as f64, mem_weight as f64) > } > =20 > /// Method: Scores the given migration `candidates` by the best node= imbalance improvement with > @@ -181,6 +187,8 @@ pub mod pve_rs_resource_scheduling_dynamic { > #[try_from_ref] this: &Scheduler, > candidates: Vec, > limit: usize, > + cpu_weight: usize, > + mem_weight: usize, > ) -> Result, Error> { > let usage =3D this.inner.lock().unwrap(); > =20 [ -->8- snip -8<-- ]