From 8515d29f2a005c6e7ae595d0badd9eef48c7f7d2 Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Thu, 7 Oct 2021 15:50:55 +0200 Subject: [PATCH] fix and simplify checking of slots --- pkg/cluster/sync.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/pkg/cluster/sync.go b/pkg/cluster/sync.go index 5f006b301..a0d8c0748 100644 --- a/pkg/cluster/sync.go +++ b/pkg/cluster/sync.go @@ -540,20 +540,18 @@ func (c *Cluster) checkAndSetGlobalPostgreSQLConfiguration(pod *v1.Pod, patroniC configToSet["ttl"] = desiredPatroniConfig.TTL } - // only check if specified slots exist in config and if they differ + // check if specified slots exist in config and if they differ + slotsToSet := make(map[string]map[string]string) for slotName, desiredSlot := range desiredPatroniConfig.Slots { - desiredSlots := make(map[string]map[string]string) if effectiveSlot, exists := patroniConfig.Slots[slotName]; exists { - if !reflect.DeepEqual(desiredSlot, effectiveSlot) { - desiredSlots[slotName] = desiredSlot + if reflect.DeepEqual(desiredSlot, effectiveSlot) { + continue } - } else { - desiredSlots[slotName] = desiredSlot - } - - if len(desiredSlots) > 0 { - configToSet["slots"] = desiredSlots } + slotsToSet[slotName] = desiredSlot + } + if len(slotsToSet) > 0 { + configToSet["slots"] = slotsToSet } if len(configToSet) == 0 {