[PATCH proxmox v3 01/40] resource-scheduling: inline add_cpu_usage in score_nodes_to_start_service

Daniel Kral
2026-03-30T14:42:02Z

This makes moving the function out into its own module easier to follow,
which in turn is needed to generalize score_nodes_to_start_service(...)
for other usage stats in the following patches.

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
Reviewed-by: Dominik Rusovac <d.rusovac@proxmox.com>
---
changes v2 -> v3:
- none

proxmox-resource-scheduling/src/pve_static.rs | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/proxmox-resource-scheduling/src/pve_static.rs b/proxmox-resource-scheduling/src/pve_static.rs
index b81086dd..fd5e5ffc 100644
--- a/proxmox-resource-scheduling/src/pve_static.rs
+++ b/proxmox-resource-scheduling/src/pve_static.rs
@@ -94,7 +94,11 @@ pub fn score_nodes_to_start_service<T: AsRef<StaticNodeUsage>>(
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)
+ if service.maxcpu == 0.0 {
+ node.cpu + node.maxcpu as f64
+ } else {
+ node.cpu + service.maxcpu
+ }
} else {
node.cpu
} / (node.maxcpu as f64);
--
2.47.3