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

Dominik Rusovac
2026-03-26T10:10:20Z

lgtm

On Tue Mar 24, 2026 at 7:29 PM CET, Daniel Kral wrote:
> 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>
> ---
> changes v1 -> v2:
> - new!
>
> 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);