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 860191FF141 for ; Mon, 30 Mar 2026 15:06:09 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 09C3730429; Mon, 30 Mar 2026 15:06:36 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 30 Mar 2026 15:06:29 +0200 Message-Id: Subject: Re: [PATCH ha-manager v2 31/40] usage: add dynamic usage scheduler From: "Daniel Kral" To: "Dominik Rusovac" , X-Mailer: aerc 0.21.0-38-g7088c3642f2c-dirty References: <20260324183029.1274972-1-d.kral@proxmox.com> <20260324183029.1274972-32-d.kral@proxmox.com> In-Reply-To: X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1774875935723 X-SPAM-LEVEL: Spam detection results: 0 AWL -1.439 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: XBLPSCPAFC5BSZVUDHOE26KKLWSZSA5X X-Message-ID-Hash: XBLPSCPAFC5BSZVUDHOE26KKLWSZSA5X X-MailFrom: d.kral@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: On Mon Mar 30, 2026 at 1:17 PM CEST, Dominik Rusovac wrote: > 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" > Thanks, but NACK this for now to have consistent error messages with PVE::HA::Usage::Static. Can be done in a single patch in the future to change both at the same time though! >> + >> + 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 '$nodena= me'\n"; > > nit: consider rewording "did not get" to "could not retrieve" > Same here >> + die "dynamic node usage information for '$nodename' missing cpu cou= nt\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 co= unt\n"=20 > if !defined($stats->{maxcpu}); > die "dynamic node usage information for '$nodename' missing memory= \n"=20 > if !defined($stats->{maxmem}); > Good catch, thanks! >> + >> + eval { $self->{scheduler}->add_node($nodename, $stats); }; >> + die "initializing dynamic node usage for '$nodename' failed - $@" i= f $@; >> +} > > [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" > Same here >> + >> + 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] Will do so! > > Reviewed-by: Dominik Rusovac