From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pve-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 761D21FF15E for <inbox@lore.proxmox.com>; Tue, 25 Mar 2025 16:13:38 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9A962CB59; Tue, 25 Mar 2025 16:13:09 +0100 (CET) From: Daniel Kral <d.kral@proxmox.com> To: pve-devel@lists.proxmox.com Date: Tue, 25 Mar 2025 16:12:46 +0100 Message-Id: <20250325151254.193177-9-d.kral@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250325151254.193177-1-d.kral@proxmox.com> References: <20250325151254.193177-1-d.kral@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.010 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 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 07/15] manager: read and update rules config X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> List-Post: <mailto:pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com> Read the rules configuration in each round and update the canonicalized rules configuration if there were any changes since the last round to reduce the amount of times of verifying the rule set. Signed-off-by: Daniel Kral <d.kral@proxmox.com> --- As noted inline already, there's a missing check whether the service configuration changed, which includes the HA group assignment (and is only needed for these), since there's no digest as for groups/rules. I was hesitant to change the structure of `%sc` or the return value of `read_service_config()` as it's used quite often and didn't want to create a sha1 digest here just for this check. This is another plus point to have all of these constraints in a single configuration file. src/PVE/HA/Manager.pm | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm index d983672..7a8e7dc 100644 --- a/src/PVE/HA/Manager.pm +++ b/src/PVE/HA/Manager.pm @@ -11,6 +11,9 @@ use PVE::HA::NodeStatus; use PVE::HA::Usage::Basic; use PVE::HA::Usage::Static; +use PVE::HA::Rules; +use PVE::HA::Rules::Colocation; + ## Variable Name & Abbreviations Convention # # The HA stack has some variables it uses frequently and thus abbreviates it such that it may be @@ -41,7 +44,12 @@ sub new { my $class = ref($this) || $this; - my $self = bless { haenv => $haenv, crs => {} }, $class; + my $self = bless { + haenv => $haenv, + crs => {}, + last_rules_digest => '', + last_groups_digest => '', + }, $class; my $old_ms = $haenv->read_manager_status(); @@ -497,6 +505,19 @@ sub manage { delete $ss->{$sid}; } + my $new_rules = $haenv->read_rules_config(); + + # TODO We should also check for a service digest here, but we would've to + # calculate it here independently or also expose it through read_service_config() + if ($new_rules->{digest} ne $self->{last_rules_digest} + || $self->{groups}->{digest} ne $self->{last_groups_digest}) { + $self->{rules} = $new_rules; + PVE::HA::Rules::checked_config($self->{rules}, $self->{groups}, $sc); + } + + $self->{last_rules_digest} = $self->{rules}->{digest}; + $self->{last_groups_digest} = $self->{groups}->{digest}; + $self->update_crm_commands(); for (;;) { -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel