From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 5009A1FF15C for ; Fri, 14 Nov 2025 11:06:46 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 43B53CCAA; Fri, 14 Nov 2025 11:07:18 +0100 (CET) From: Daniel Kral To: pve-devel@lists.proxmox.com Date: Fri, 14 Nov 2025 11:06:14 +0100 Message-ID: <20251114100641.92919-3-d.kral@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114100641.92919-1-d.kral@proxmox.com> References: <20251114100641.92919-1-d.kral@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1763114778296 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.015 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH proxmox v4 2/2] resource-scheduling: allow owned nodes slice for score_nodes_to_start_service X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" This is needed to allow StaticNodeUsage to be passed as a owned value in PVE::RS::ResourceScheduling::Static::score_nodes_to_start_service. Signed-off-by: Daniel Kral --- changes since v3: - remove R-b from Fiona because... - do not change the signature of score_nodes_to_start_service but generic to accept nodes as &[T] where T: AsRef - doesn't need a versioned break anymore proxmox-resource-scheduling/src/pve_static.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/proxmox-resource-scheduling/src/pve_static.rs b/proxmox-resource-scheduling/src/pve_static.rs index d39614cd..b81086dd 100644 --- a/proxmox-resource-scheduling/src/pve_static.rs +++ b/proxmox-resource-scheduling/src/pve_static.rs @@ -27,6 +27,12 @@ impl StaticNodeUsage { } } +impl AsRef for StaticNodeUsage { + fn as_ref(&self) -> &Self { + self + } +} + /// Calculate new CPU usage in percent. /// `add` being `0.0` means "unlimited" and results in `max` being added. fn add_cpu_usage(old: f64, max: f64, add: f64) -> f64 { @@ -69,8 +75,8 @@ criteria_struct! { /// /// Returns a vector of (nodename, score) pairs. Scores are between 0.0 and 1.0 and a higher score /// is better. -pub fn score_nodes_to_start_service( - nodes: &[&StaticNodeUsage], +pub fn score_nodes_to_start_service>( + nodes: &[T], service: &StaticServiceUsage, ) -> Result, Error> { let len = nodes.len(); @@ -86,6 +92,7 @@ pub fn score_nodes_to_start_service( let mut squares_mem = 0.0; for (index, node) in nodes.iter().enumerate() { + let node = node.as_ref(); let new_cpu = if index == target_index { add_cpu_usage(node.cpu, node.maxcpu as f64, service.maxcpu) } else { @@ -122,6 +129,6 @@ pub fn score_nodes_to_start_service( Ok(scores .into_iter() .enumerate() - .map(|(n, score)| (nodes[n].name.clone(), score)) + .map(|(n, score)| (nodes[n].as_ref().name.clone(), score)) .collect()) } -- 2.47.3 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel