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.k...@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