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 28A7A1FF15C for ; Fri, 17 Oct 2025 13:56:53 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0D1A8BDA; Fri, 17 Oct 2025 13:57:13 +0200 (CEST) Message-ID: <32d961a6-8b46-45a7-b240-856326d2e806@proxmox.com> Date: Fri, 17 Oct 2025 13:57:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Proxmox VE development discussion , Daniel Kral References: <20250930142021.366529-1-d.kral@proxmox.com> <20250930142021.366529-11-d.kral@proxmox.com> Content-Language: en-US From: Fiona Ebner In-Reply-To: <20250930142021.366529-11-d.kral@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1760702226105 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.021 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH ha-manager 7/9] usage: allow granular changes to Usage implementations 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" 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 Reviewed-by: Fiona Ebner 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