Skip to content

Commit 5ae08d7

Browse files
committed
apply feedback
1 parent 2feeb65 commit 5ae08d7

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

pkg/cluster/cluster.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ type Cluster struct {
8484
userSyncStrategy spec.UserSyncer
8585
deleteOptions metav1.DeleteOptions
8686
podEventsQueue *cache.FIFO
87+
replicationSlots map[string]interface{}
8788

8889
teamsAPIClient teams.Interface
8990
oauthTokenGetter OAuthTokenGetter
@@ -141,6 +142,7 @@ func New(cfg Config, kubeClient k8sutil.KubernetesClient, pgSpec acidv1.Postgres
141142
podEventsQueue: podEventsQueue,
142143
KubeClient: kubeClient,
143144
currentMajorVersion: 0,
145+
replicationSlots: make(map[string]interface{}),
144146
}
145147
cluster.logger = logger.WithField("pkg", "cluster").WithField("cluster-name", cluster.clusterName())
146148
cluster.teamsAPIClient = teams.NewTeamsAPI(cfg.OpConfig.TeamsAPIUrl, logger)
@@ -375,6 +377,12 @@ func (c *Cluster) Create() error {
375377
}
376378
}
377379

380+
if len(c.Spec.Patroni.Slots) > 0 {
381+
for slotName, desiredSlot := range c.Spec.Patroni.Slots {
382+
c.replicationSlots[slotName] = desiredSlot
383+
}
384+
}
385+
378386
return nil
379387
}
380388

pkg/cluster/sync.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,13 +581,14 @@ func (c *Cluster) checkAndSetGlobalPostgreSQLConfiguration(pod *v1.Pod, effectiv
581581

582582
slotsToSet := make(map[string]interface{})
583583
// check if there is any slot deletion
584-
for slotName, effectiveSlot := range effectivePatroniConfig.Slots {
584+
for slotName, effectiveSlot := range c.replicationSlots {
585585
if desiredSlot, exists := desiredPatroniConfig.Slots[slotName]; exists {
586586
if reflect.DeepEqual(effectiveSlot, desiredSlot) {
587587
continue
588588
}
589589
}
590590
slotsToSet[slotName] = nil
591+
delete(c.replicationSlots, slotName)
591592
}
592593
// check if specified slots exist in config and if they differ
593594
for slotName, desiredSlot := range desiredPatroniConfig.Slots {
@@ -597,6 +598,7 @@ func (c *Cluster) checkAndSetGlobalPostgreSQLConfiguration(pod *v1.Pod, effectiv
597598
}
598599
}
599600
slotsToSet[slotName] = desiredSlot
601+
c.replicationSlots[slotName] = desiredSlot
600602
}
601603
if len(slotsToSet) > 0 {
602604
configToSet["slots"] = slotsToSet

0 commit comments

Comments
 (0)