From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 022C39404 for ; Thu, 17 Nov 2022 15:01:24 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id ED99C2D66B for ; Thu, 17 Nov 2022 15:00:28 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 17 Nov 2022 15:00:26 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 1A77644D96 for ; Thu, 17 Nov 2022 15:00:24 +0100 (CET) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Thu, 17 Nov 2022 15:00:14 +0100 Message-Id: <20221117140018.105004-14-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221117140018.105004-1-f.ebner@proxmox.com> References: <20221117140018.105004-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: =?UTF-8?Q?0=0A=09?=AWL 0.027 Adjusted score from AWL reputation of From: =?UTF-8?Q?address=0A=09?=BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict =?UTF-8?Q?Alignment=0A=09?=SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF =?UTF-8?Q?Record=0A=09?=SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH v2 ha-manager 13/15] usage: static: use service count on nodes as a fallback 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: , X-List-Received-Date: Thu, 17 Nov 2022 14:01:24 -0000 if something goes wrong with the TOPSIS scoring. Not expected to happen, but it's rather cheap to be on the safe side. Signed-off-by: Fiona Ebner --- New in v2. src/PVE/HA/Usage/Static.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/PVE/HA/Usage/Static.pm b/src/PVE/HA/Usage/Static.pm index ce705eb..73ce836 100644 --- a/src/PVE/HA/Usage/Static.pm +++ b/src/PVE/HA/Usage/Static.pm @@ -22,12 +22,15 @@ sub new { 'service-stats' => {}, haenv => $haenv, scheduler => $scheduler, + 'service-counts' => {}, # Service count on each node. Fallback if scoring calculation fails. }, $class; } sub add_node { my ($self, $nodename) = @_; + $self->{'service-counts'}->{$nodename} = 0; + my $stats = $self->{'node-stats'}->{$nodename} or die "did not get static node usage information for '$nodename'\n"; die "static node usage information for '$nodename' missing cpu count\n" if !$stats->{cpus}; @@ -40,6 +43,8 @@ sub add_node { sub remove_node { my ($self, $nodename) = @_; + delete $self->{'service-counts'}->{$nodename}; + $self->{scheduler}->remove_node($nodename); } @@ -83,6 +88,8 @@ my sub get_service_usage { sub add_service_usage_to_node { my ($self, $nodename, $sid, $service_node, $migration_target) = @_; + $self->{'service-counts'}->{$nodename}++; + eval { my $service_usage = get_service_usage($self, $sid, $service_node, $migration_target); $self->{scheduler}->add_service_usage_to_node($nodename, $service_usage); @@ -103,8 +110,7 @@ sub score_nodes_to_start_service { 'err', "unable to score nodes according to static usage for service '$sid' - $err", ); - # TODO maybe use service count as fallback? - return { map { $_ => 1 } $self->list_nodes() }; + return $self->{'service-counts'}; } # Take minus the value, so that a lower score is better, which our caller(s) expect(s). -- 2.30.2