@@ -541,45 +541,6 @@ func (c *Cluster) checkAndSetGlobalPostgreSQLConfiguration(pod *v1.Pod, effectiv
541541 configPatched := false
542542 requiresMasterRestart := false
543543
544- for slotName , _ := range effectivePatroniConfig .Slots {
545- if _ , exists := desiredPatroniConfig .Slots [slotName ]; exists {
546- continue
547- }
548-
549- configToRewrite := make (map [string ]interface {})
550- configToRewrite ["loop_wait" ] = effectivePatroniConfig .LoopWait
551- configToRewrite ["maximum_lag_on_failover" ] = effectivePatroniConfig .MaximumLagOnFailover
552- configToRewrite ["pg_hba" ] = effectivePatroniConfig .PgHba
553- configToRewrite ["retry_timeout" ] = effectivePatroniConfig .RetryTimeout
554- configToRewrite ["synchronous_mode" ] = effectivePatroniConfig .SynchronousMode
555- configToRewrite ["synchronous_mode_strict" ] = effectivePatroniConfig .SynchronousModeStrict
556- configToRewrite ["ttl" ] = effectivePatroniConfig .TTL
557- configToRewrite ["postgresql" ] = map [string ]interface {}{constants .PatroniPGParametersParameterName : effectivePgParameters }
558-
559- slotsToRewrite := make (map [string ]map [string ]string )
560- for slotName , desiredSlot := range desiredPatroniConfig .Slots {
561- slotsToRewrite [slotName ] = desiredSlot
562- }
563-
564- if len (slotsToRewrite ) > 0 {
565- configToRewrite ["slots" ] = slotsToRewrite
566- }
567-
568- configToRewriteJson , err := json .Marshal (configToRewrite )
569- if err != nil {
570- c .logger .Debugf ("could not convert config rewrite to JSON: %v" , err )
571- }
572-
573- podName := util .NameFromMeta (pod .ObjectMeta )
574- c .logger .Debugf ("rewrite Postgres config via Patroni API on pod %s with following options: %s" ,
575- podName , configToRewriteJson )
576- if err = c .patroni .RewriteConfig (pod , configToRewrite ); err != nil {
577- return configPatched , requiresMasterRestart , fmt .Errorf ("could not rewrite postgres parameters within pod %s: %v" , podName , err )
578- }
579-
580- break
581- }
582-
583544 // compare effective and desired Patroni config options
584545 if desiredPatroniConfig .LoopWait > 0 && desiredPatroniConfig .LoopWait != effectivePatroniConfig .LoopWait {
585546 configToSet ["loop_wait" ] = desiredPatroniConfig .LoopWait
@@ -618,8 +579,8 @@ func (c *Cluster) checkAndSetGlobalPostgreSQLConfiguration(pod *v1.Pod, effectiv
618579 }
619580 }
620581
582+ slotsToSet := make (map [string ]interface {})
621583 // check if specified slots exist in config and if they differ
622- slotsToSet := make (map [string ]map [string ]string )
623584 for slotName , desiredSlot := range desiredPatroniConfig .Slots {
624585 if effectiveSlot , exists := effectivePatroniConfig .Slots [slotName ]; exists {
625586 if reflect .DeepEqual (desiredSlot , effectiveSlot ) {
@@ -628,6 +589,15 @@ func (c *Cluster) checkAndSetGlobalPostgreSQLConfiguration(pod *v1.Pod, effectiv
628589 }
629590 slotsToSet [slotName ] = desiredSlot
630591 }
592+ // check if there is any slot deletion
593+ for slotName , effectiveSlot := range effectivePatroniConfig .Slots {
594+ if desiredSlot , exists := desiredPatroniConfig .Slots [slotName ]; exists {
595+ if reflect .DeepEqual (effectiveSlot , desiredSlot ) {
596+ continue
597+ }
598+ }
599+ slotsToSet [slotName ] = nil
600+ }
631601 if len (slotsToSet ) > 0 {
632602 configToSet ["slots" ] = slotsToSet
633603 }
0 commit comments