[pve-devel] [PATCH proxmox v3 1/1] resource-scheduling: change score_nodes_to_start_service signature
Thomas Lamprecht
t.lamprecht at proxmox.com
Wed Nov 12 12:01:02 CET 2025
Am 27.10.25 um 17:46 schrieb Daniel Kral:
> This is needed as StaticNodeUsage is created in each invocation of
> PVE::RS::ResourceScheduling::Static::score_nodes_to_start_service now.
>
> Signed-off-by: Daniel Kral <d.kral at proxmox.com>
> Reviewed-by: Fiona Ebner <f.ebner at proxmox.com>
> ---
> proxmox-resource-scheduling/src/pve_static.rs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/proxmox-resource-scheduling/src/pve_static.rs b/proxmox-resource-scheduling/src/pve_static.rs
> index d39614cd..fc40cb5c 100644
> --- a/proxmox-resource-scheduling/src/pve_static.rs
> +++ b/proxmox-resource-scheduling/src/pve_static.rs
> @@ -70,7 +70,7 @@ 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],
> + nodes: &[StaticNodeUsage],
Or keep it backward compatible using generics and an AsRef bound:
pub fn score_nodes_to_start_service<T: AsRef<StaticNodeUsage>>(
nodes: &[T],
) {
Not something I'd heavily promote do always do, but for one such changes are
not required very often in the first place, and being able to bump and roll
out this while still allowing to build and bump pve-rs without your changes
there has its small benefits.
That said, generics will result in multiple copies of the function (one per
actual type used), but that is mostly a problem for bigger methods, albeit
there one often can move the actual impl to a dedicated private fn and let
the public fn just handle "resolving" the generics and calling into the
actual impl). Here we will just use a single type anyway, just switching that
from a ref to a value, so the generic has no real practical cost for us and
thus would be worthwhile.
> service: &StaticServiceUsage,
> ) -> Result<Vec<(String, f64)>, Error> {
> let len = nodes.len();
More information about the pve-devel
mailing list