]> git.proxmox.com Git - pve-ha-manager.git/commitdiff
manager: use static resource scheduler when configured
authorFiona Ebner <f.ebner@proxmox.com>
Thu, 17 Nov 2022 14:00:11 +0000 (15:00 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 18 Nov 2022 12:25:21 +0000 (13:25 +0100)
Note that recompute_online_node_usage() becomes much slower when the
'static' resource scheduler mode is used. Tested it with ~300 HA
services (minimal containers) running on my virtual test cluster.

Timings with 'basic' mode were between 0.0004 - 0.001 seconds
Timings with 'static' mode were between 0.007 - 0.012 seconds

Combined with the fact that recompute_online_node_usage() is currently
called very often this can lead to a lot of delay during recovery
situations with hundreds of services and low thousands of services
overall and with genereous estimates even run into the watchdog timer.

Ideas to remedy this is using PVE::Cluster's
get_guest_config_properties() instead of load_config() and/or
optimizing how often recompute_online_node_usage() is called.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
src/PVE/HA/Manager.pm

index 16384425adf860725dba7e1a85e8d212168095c2..7f1d1d7f8e8f28ed4ce5063711d4290bbf453de8 100644 (file)
@@ -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
 #
@@ -203,14 +204,35 @@ my $valid_service_states = {
     error => 1,
 };
 
+# FIXME with 'static' mode and thousands of services, the overhead can be noticable and the fact
+# that this function is called for each state change and upon recovery doesn't help.
 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};