Skip to content

Commit 6149711

Browse files
committed
apply feedback
1 parent be68153 commit 6149711

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)
@@ -371,6 +373,12 @@ func (c *Cluster) Create() error {
371373
}
372374
}
373375

376+
if len(c.Spec.Patroni.Slots) > 0 {
377+
for slotName, desiredSlot := range c.Spec.Patroni.Slots {
378+
c.replicationSlots[slotName] = desiredSlot
379+
}
380+
}
381+
374382
return nil
375383
}
376384

pkg/cluster/sync.go

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

571571
slotsToSet := make(map[string]interface{})
572572
// check if there is any slot deletion
573-
for slotName, effectiveSlot := range effectivePatroniConfig.Slots {
573+
for slotName, effectiveSlot := range c.replicationSlots {
574574
if desiredSlot, exists := desiredPatroniConfig.Slots[slotName]; exists {
575575
if reflect.DeepEqual(effectiveSlot, desiredSlot) {
576576
continue
577577
}
578578
}
579579
slotsToSet[slotName] = nil
580+
delete(c.replicationSlots, slotName)
580581
}
581582
// check if specified slots exist in config and if they differ
582583
for slotName, desiredSlot := range desiredPatroniConfig.Slots {
@@ -586,6 +587,7 @@ func (c *Cluster) checkAndSetGlobalPostgreSQLConfiguration(pod *v1.Pod, effectiv
586587
}
587588
}
588589
slotsToSet[slotName] = desiredSlot
590+
c.replicationSlots[slotName] = desiredSlot
589591
}
590592
if len(slotsToSet) > 0 {
591593
configToSet["slots"] = slotsToSet

0 commit comments

Comments
 (0)