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 AADEB1FF164 for <inbox@lore.proxmox.com>; Fri, 25 Apr 2025 16:30:43 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D44193570B; Fri, 25 Apr 2025 16:30:50 +0200 (CEST) Message-ID: <cd302144-9018-4fbc-b83a-226bc24bc25e@proxmox.com> Date: Fri, 25 Apr 2025 16:30:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>, Daniel Kral <d.kral@proxmox.com> References: <20250325151254.193177-1-d.kral@proxmox.com> <20250325151254.193177-9-d.kral@proxmox.com> Content-Language: en-US From: Fiona Ebner <f.ebner@proxmox.com> In-Reply-To: <20250325151254.193177-9-d.kral@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL -0.037 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 0.001 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 0.001 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 0.001 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [manager.pm] Subject: Re: [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> Am 25.03.25 um 16:12 schrieb Daniel Kral: > 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; Nit: there should be no blank, should be ordered alphabetically > + > ## 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() Ah, so read_and_check_resources_config() drops the digest and produces a hash with the only keys being the $sids. Easiest is probably to add wantarray in the relevant place(s) and return a list with the digest second. And I guess we don't need that anymore after we migrated from HA groups to location rules, since it's only used to get the groups? If yes, then we should add a reminder to remove it again. > + 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); Might not matter now, but I'd prefer: check first, then assign. > + } > + > + $self->{last_rules_digest} = $self->{rules}->{digest}; > + $self->{last_groups_digest} = $self->{groups}->{digest}; > + > $self->update_crm_commands(); > > for (;;) { _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel