From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id B7FFC1FF137 for ; Tue, 17 Feb 2026 15:15:57 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 465EA354A; Tue, 17 Feb 2026 15:15:19 +0100 (CET) From: Daniel Kral To: pve-devel@lists.proxmox.com Subject: [RFC perl-rs 1/6] pve-rs: resource scheduling: use generic cluster usage implementation Date: Tue, 17 Feb 2026 15:14:00 +0100 Message-ID: <20260217141437.584852-7-d.kral@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260217141437.584852-1-d.kral@proxmox.com> References: <20260217141437.584852-1-d.kral@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1771337676316 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.019 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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: MWZY6HUMMZS4VBFNZWUUVJEZROSA55UM X-Message-ID-Hash: MWZY6HUMMZS4VBFNZWUUVJEZROSA55UM 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: Signed-off-by: Daniel Kral --- In general, in a v2 or later series this could be generalized for the static and (upcoming) dynamic use case and moved to proxmox-resource-scheduling as well to make the perlmod bindings as thin as possible (to allow flexibility in the internals and not introduce unnecessary build breaks). .../bindings/resource_scheduling_static.rs | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/pve-rs/src/bindings/resource_scheduling_static.rs b/pve-rs/src/bindings/resource_scheduling_static.rs index 5b91d36..a51b8a2 100644 --- a/pve-rs/src/bindings/resource_scheduling_static.rs +++ b/pve-rs/src/bindings/resource_scheduling_static.rs @@ -13,6 +13,7 @@ pub mod pve_rs_resource_scheduling_static { use perlmod::Value; use proxmox_resource_scheduling::pve_static::{StaticNodeUsage, StaticServiceUsage}; + use proxmox_resource_scheduling::scheduler::ClusterUsage; perlmod::declare_magic!(Box : &Scheduler as "PVE::RS::ResourceScheduling::Static"); @@ -175,21 +176,7 @@ pub mod pve_rs_resource_scheduling_static { Ok(()) } - /// Scores all previously added nodes for starting a `service` on. - /// - /// Scoring is done according to the static memory and CPU usages of the nodes as if the - /// service would already be running on each. - /// - /// Returns a vector of (nodename, score) pairs. Scores are between 0.0 and 1.0 and a higher - /// score is better. - /// - /// See [`proxmox_resource_scheduling::pve_static::score_nodes_to_start_service`]. - #[export] - pub fn score_nodes_to_start_service( - #[try_from_ref] this: &Scheduler, - service: StaticServiceUsage, - ) -> Result, Error> { - let usage = this.inner.lock().unwrap(); + fn as_cluster_usage(usage: &Usage) -> ClusterUsage { let nodes = usage .nodes .values() @@ -208,8 +195,28 @@ pub mod pve_rs_resource_scheduling_static { node_usage }) - .collect::>(); + .collect::>(); - proxmox_resource_scheduling::pve_static::score_nodes_to_start_service(&nodes, &service) + ClusterUsage::from_nodes(nodes) + } + + /// Scores all previously added nodes for starting a `service` on. + /// + /// Scoring is done according to the static memory and CPU usages of the nodes as if the + /// service would already be running on each. + /// + /// Returns a vector of (nodename, score) pairs. Scores are between 0.0 and 1.0 and a higher + /// score is better. + /// + /// See [`proxmox_resource_scheduling::pve_static::score_nodes_to_start_service`]. + #[export] + pub fn score_nodes_to_start_service( + #[try_from_ref] this: &Scheduler, + service: StaticServiceUsage, + ) -> Result, Error> { + let usage = this.inner.lock().unwrap(); + let cluster_usage = as_cluster_usage(&usage); + + cluster_usage.score_nodes_to_start_service(service) } } -- 2.47.3