public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
	Daniel Kral <d.kral@proxmox.com>
Subject: Re: [pve-devel] [PATCH ha-manager 7/9] usage: allow granular changes to Usage implementations
Date: Fri, 17 Oct 2025 13:57:09 +0200	[thread overview]
Message-ID: <32d961a6-8b46-45a7-b240-856326d2e806@proxmox.com> (raw)
In-Reply-To: <20250930142021.366529-11-d.kral@proxmox.com>

Am 30.09.25 um 4:20 PM schrieb Daniel Kral:
> This makes use of the new signature for add_service_usage_to_node(...)
> from the Proxmox::RS::ResourceScheduling::Static package, which allows
> tracking of which HA resources have been assigned to which nodes.
> 
> Signed-off-by: Daniel Kral <d.kral@proxmox.com>

Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>

with some style nits below:

(also good to have a note: dependency bump for pve-rs needed)

> @@ -51,10 +51,18 @@ sub add_service_usage_to_node {
>      }
>  }
>  
> +sub remove_service_usage {
> +    my ($self, $sid) = @_;
> +
> +    for my $node ($self->list_nodes()) {
> +        delete $self->{nodes}->{$node}->{$sid};
> +    }
> +}
> +
>  sub score_nodes_to_start_service {
>      my ($self, $sid, $service_node) = @_;
>  
> -    return $self->{nodes};
> +    return { map { $_ => scalar keys $self->{nodes}->{$_}->%* } keys $self->{nodes}->%* };

Style nit: I feel like 'scalar' is more readable when surrounding its
argument with parentheses.

Style nit: Maybe add
my $nodes = $self->{nodes};
up front to defuse the lengthy expression a bit?

> @@ -89,16 +89,27 @@ my sub get_service_usage {
>  sub add_service_usage_to_node {
>      my ($self, $nodename, $sid, $service_node, $migration_target) = @_;
>  
> -    $self->{'service-counts'}->{$nodename}++;
> +    $self->{'node-services'}->{$nodename}->{$sid} = 1;
>  
>      eval {
>          my $service_usage = get_service_usage($self, $sid, $service_node, $migration_target);
> -        $self->{scheduler}->add_service_usage_to_node($nodename, $service_usage);
> +        $self->{scheduler}->add_service_usage_to_node($nodename, $sid, $service_usage);
>      };
>      $self->{haenv}->log('warning', "unable to add service '$sid' usage to node '$nodename' - $@")
>          if $@;
>  }
>  
> +sub remove_service_usage {
> +    my ($self, $sid) = @_;
> +
> +    delete $self->{'node-services'}->{$_}->{$sid} for $self->list_nodes();

Style nit: add parentheses for the delete(), since other code follows it
(and the argument is quite lengthy too):
https://pve.proxmox.com/wiki/Perl_Style_Guide#Perl_syntax_choices

> +
> +    eval { $self->{scheduler}->remove_service_usage($sid) };
> +    $self->{haenv}->log('warning', "unable to remove service '$sid' usage - $@") if $@;
> +
> +    delete $self->{'service-stats'}->{$sid}; # Invalidate old service stats
> +}
> +
>  sub score_nodes_to_start_service {
>      my ($self, $sid, $service_node) = @_;
>  
> @@ -111,7 +122,10 @@ sub score_nodes_to_start_service {
>              'err',
>              "unable to score nodes according to static usage for service '$sid' - $err",
>          );
> -        return $self->{'service-counts'};
> +        return {
> +            map { $_ => scalar keys $self->{'node-services'}->{$_}->%* }

Style nit: same as above regarding parentheses and using a variable to
improve the readability

> +                keys $self->{'node-services'}->%*
> +        };
>      }
>  
>      # Take minus the value, so that a lower score is better, which our caller(s) expect(s).



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  reply	other threads:[~2025-10-17 11:56 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-30 14:19 [pve-devel] [RFC ha-manager/perl-rs/proxmox/qemu-server 00/12] Granular online_node_usage accounting Daniel Kral
2025-09-30 14:19 ` [pve-devel] [PATCH qemu-server 1/1] config: only fetch necessary default values in get_derived_property helper Daniel Kral
2025-10-15 14:31   ` Fiona Ebner
2025-10-16  9:07     ` Daniel Kral
2025-09-30 14:19 ` [pve-devel] [PATCH proxmox 1/1] resource-scheduling: change score_nodes_to_start_service signature Daniel Kral
2025-09-30 14:19 ` [pve-devel] [PATCH perl-rs 1/1] pve-rs: resource_scheduling: allow granular usage changes Daniel Kral
2025-10-16 10:32   ` Fiona Ebner
2025-10-16 15:34     ` Daniel Kral
2025-10-17 10:55       ` Fiona Ebner
2025-09-30 14:19 ` [pve-devel] [PATCH ha-manager 1/9] implement static service stats cache Daniel Kral
2025-10-16 11:12   ` Fiona Ebner
2025-10-16 15:15     ` Daniel Kral
2025-10-17 10:02       ` Fiona Ebner
2025-10-17 10:08         ` Fiona Ebner
2025-10-17 16:18           ` Daniel Kral
2025-09-30 14:19 ` [pve-devel] [PATCH ha-manager 2/9] manager: remove redundant recompute_online_node_usage from next_state_recovery Daniel Kral
2025-10-16 11:25   ` Fiona Ebner
2025-09-30 14:19 ` [pve-devel] [PATCH ha-manager 3/9] manager: remove redundant add_service_usage_to_node " Daniel Kral
2025-10-16 11:33   ` Fiona Ebner
2025-09-30 14:19 ` [pve-devel] [PATCH ha-manager 4/9] manager: remove redundant add_service_usage_to_node from next_state_started Daniel Kral
2025-10-16 11:39   ` Fiona Ebner
2025-09-30 14:19 ` [pve-devel] [PATCH ha-manager 5/9] rules: resource affinity: decouple get_resource_affinity helper from Usage class Daniel Kral
2025-10-17 11:14   ` Fiona Ebner
2025-10-17 15:46     ` Daniel Kral
2025-10-20 15:18       ` Fiona Ebner
2025-09-30 14:19 ` [pve-devel] [PATCH ha-manager 6/9] manager: make recompute_online_node_usage use get_service_nodes helper Daniel Kral
2025-10-17 11:25   ` Fiona Ebner
2025-09-30 14:19 ` [pve-devel] [PATCH ha-manager 7/9] usage: allow granular changes to Usage implementations Daniel Kral
2025-10-17 11:57   ` Fiona Ebner [this message]
2025-09-30 14:19 ` [pve-devel] [PATCH ha-manager 8/9] manager: make online node usage computation granular Daniel Kral
2025-10-17 12:32   ` Fiona Ebner
2025-10-17 16:07     ` Daniel Kral
2025-09-30 14:19 ` [pve-devel] [PATCH ha-manager 9/9] manager: make service node usage computation more granular Daniel Kral
2025-10-17 12:42   ` Fiona Ebner
2025-10-17 15:59     ` Daniel Kral
2025-10-20 16:50 ` [pve-devel] superseded: [RFC ha-manager/perl-rs/proxmox/qemu-server 00/12] Granular online_node_usage accounting Daniel Kral

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=32d961a6-8b46-45a7-b240-856326d2e806@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=d.kral@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal