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 468ED8E158 for ; Thu, 10 Nov 2022 15:38:17 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2146E28B35 for ; Thu, 10 Nov 2022 15:38:17 +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, 10 Nov 2022 15:38:11 +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 1865744B7D for ; Thu, 10 Nov 2022 15:38:07 +0100 (CET) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Thu, 10 Nov 2022 15:37:57 +0100 Message-Id: <20221110143800.98047-19-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221110143800.98047-1-f.ebner@proxmox.com> References: <20221110143800.98047-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.028 Adjusted score from AWL reputation of From: address 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 Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH ha-manager 09/11] manager: use static resource scheduler when configured 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, 10 Nov 2022 14:38:17 -0000 Signed-off-by: Fiona Ebner --- src/PVE/HA/Manager.pm | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm index 20b743c..7c85b67 100644 --- a/src/PVE/HA/Manager.pm +++ b/src/PVE/HA/Manager.pm @@ -8,6 +8,7 @@ use PVE::Tools; use PVE::HA::Tools ':exit_codes'; use PVE::HA::NodeStatus; use PVE::HA::Usage::Basic; +use PVE::HA::Usage::Static; ## Variable Name & Abbreviations Convention # @@ -206,11 +207,30 @@ my $valid_service_states = { sub recompute_online_node_usage { my ($self) = @_; - my $online_node_usage = PVE::HA::Usage::Basic->new($self->{haenv}); + my $haenv = $self->{haenv}; my $online_nodes = $self->{ns}->list_online_nodes(); - $online_node_usage->add_node($_) for $online_nodes->@*; + my $online_node_usage; + + if (my $mode = $self->{'scheduler-mode'}) { + if ($mode eq 'static') { + $online_node_usage = eval { + my $scheduler = PVE::HA::Usage::Static->new($haenv); + $scheduler->add_node($_) for $online_nodes->@*; + return $scheduler; + }; + $haenv->log('warning', "using 'basic' scheduler mode, init for 'static' failed - $@") + if $@; + } elsif ($mode ne 'basic') { + $haenv->log('warning', "got unknown scheduler mode '$mode', using 'basic'"); + } + } + + if (!$online_node_usage) { + $online_node_usage = PVE::HA::Usage::Basic->new($haenv); + $online_node_usage->add_node($_) for $online_nodes->@*; + } foreach my $sid (keys %{$self->{ss}}) { my $sd = $self->{ss}->{$sid}; -- 2.30.2