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 A43051FF141 for ; Mon, 30 Mar 2026 13:17:38 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 460B51DEFD; Mon, 30 Mar 2026 13:18:04 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 30 Mar 2026 13:17:30 +0200 Message-Id: From: "Dominik Rusovac" To: "Daniel Kral" , Subject: Re: [PATCH ha-manager v2 31/40] usage: add dynamic usage scheduler X-Mailer: aerc 0.20.0 References: <20260324183029.1274972-1-d.kral@proxmox.com> <20260324183029.1274972-32-d.kral@proxmox.com> In-Reply-To: <20260324183029.1274972-32-d.kral@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1774869396888 X-SPAM-LEVEL: Spam detection results: 0 AWL -1.116 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 1 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 1 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 1 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 4E3BIPXMLF5NIE73EHT6UOETXISNSQLE X-Message-ID-Hash: 4E3BIPXMLF5NIE73EHT6UOETXISNSQLE X-MailFrom: d.rusovac@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: lgtm, consider modulo nits and check on falsy stats On Tue Mar 24, 2026 at 7:30 PM CET, Daniel Kral wrote: > The dynamic usage scheduler allows the HA Manager to make scheduling > decisions based on the current usage of the nodes and cluster resources > in addition to the maximum usage stats as reported by the PVE::HA::Env > implementation. > > Signed-off-by: Daniel Kral > --- > changes v1 -> v2: > - guard PVE::HA::Usage::Dynamic with my $have_dynamic_scheduling as > PVE::RS::ResourceScheduling::Dynamic might not be available (as > suggested by @Thomas) > - add add_service() impl > [snip] > +sub new { > + my ($class, $haenv, $service_stats) =3D @_; > + > + my $node_stats =3D eval { $haenv->get_dynamic_node_stats() }; > + die "did not get dynamic node usage information - $@" if $@; nit: consider rewording "did not get" to "could not retrieve" > + > + my $scheduler =3D eval { PVE::RS::ResourceScheduling::Dynamic->new()= }; > + die "unable to initialize dynamic scheduling - $@" if $@; > + > + return bless { > + 'node-stats' =3D> $node_stats, > + 'service-stats' =3D> $service_stats, > + haenv =3D> $haenv, > + scheduler =3D> $scheduler, > + }, $class; > +} > + > +sub add_node { > + my ($self, $nodename) =3D @_; > + > + my $stats =3D $self->{'node-stats'}->{$nodename} > + or die "did not get dynamic node usage information for '$nodenam= e'\n"; nit: consider rewording "did not get" to "could not retrieve" > + die "dynamic node usage information for '$nodename' missing cpu coun= t\n" if !$stats->{maxcpu}; > + die "dynamic node usage information for '$nodename' missing memory\n= " if !$stats->{maxmem}; to allow for falsy 0-valued stats consider: die "dynamic node usage information for '$nodename' missing cpu coun= t\n"=20 if !defined($stats->{maxcpu}); die "dynamic node usage information for '$nodename' missing memory\n= "=20 if !defined($stats->{maxmem}); > + > + eval { $self->{scheduler}->add_node($nodename, $stats); }; > + die "initializing dynamic node usage for '$nodename' failed - $@" if= $@; > +} [snip] > +my sub get_service_usage { > + my ($self, $sid) =3D @_; > + > + my $service_stats =3D $self->{'service-stats'}->{$sid}->{usage} > + or die "did not get dynamic service usage information for '$sid'= \n"; nit: consider rewording "did not get" to "could not retrieve" > + > + return $service_stats; > +} > + > +sub add_service { > + my ($self, $sid, $current_node, $target_node, $running) =3D @_; > + > + # do not add service which do not put any usage on the nodes nit: # do not add service[s] [...]=20 or # do not add service, which doe[s] [...]=20 [snip] Reviewed-by: Dominik Rusovac