fix and simplify checking of slots
This commit is contained in:
		
							parent
							
								
									132122dff3
								
							
						
					
					
						commit
						8515d29f2a
					
				|  | @ -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 |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		if len(desiredSlots) > 0 { |  | ||||||
| 			configToSet["slots"] = desiredSlots |  | ||||||
| 		} | 		} | ||||||
|  | 		slotsToSet[slotName] = desiredSlot | ||||||
|  | 	} | ||||||
|  | 	if len(slotsToSet) > 0 { | ||||||
|  | 		configToSet["slots"] = slotsToSet | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if len(configToSet) == 0 { | 	if len(configToSet) == 0 { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue