fix and simplify checking of slots

This commit is contained in:
Felix Kunde 2021-10-07 15:50:55 +02:00
parent 132122dff3
commit 8515d29f2a
1 changed files with 8 additions and 10 deletions

View File

@ -540,20 +540,18 @@ func (c *Cluster) checkAndSetGlobalPostgreSQLConfiguration(pod *v1.Pod, patroniC
configToSet["ttl"] = desiredPatroniConfig.TTL 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 { for slotName, desiredSlot := range desiredPatroniConfig.Slots {
desiredSlots := make(map[string]map[string]string)
if effectiveSlot, exists := patroniConfig.Slots[slotName]; exists { if effectiveSlot, exists := patroniConfig.Slots[slotName]; exists {
if !reflect.DeepEqual(desiredSlot, effectiveSlot) { if reflect.DeepEqual(desiredSlot, effectiveSlot) {
desiredSlots[slotName] = desiredSlot continue
} }
} else {
desiredSlots[slotName] = desiredSlot
} }
slotsToSet[slotName] = desiredSlot
if len(desiredSlots) > 0 {
configToSet["slots"] = desiredSlots
} }
if len(slotsToSet) > 0 {
configToSet["slots"] = slotsToSet
} }
if len(configToSet) == 0 { if len(configToSet) == 0 {