Skip to content

Commit bc5d957

Browse files
committed
fix: do not restart on first run
Signed-off-by: Juliana Oliveira <[email protected]>
1 parent 929a98d commit bc5d957

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

internal/controller/postgrescluster/pgbouncer.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,17 @@ func (r *Reconciler) reconcilePGBouncerReconnect(
648648
return nil
649649
}
650650

651+
if lastFailoverUID == "" {
652+
// First time seeing this cluster or status field was just added.
653+
// Initialize with current primary UID without triggering pod restart.
654+
log.V(1).Info("Initializing PgBouncer failover tracking",
655+
"currentPrimaryUID", currentPrimaryUID,
656+
"currentPrimaryName", primaryPod.Name)
657+
658+
cluster.Status.Proxy.PGBouncer.LastFailoverPrimaryUID = currentPrimaryUID
659+
return nil
660+
}
661+
651662
log.Info("Primary changed, triggering PgBouncer failover signal (SIGTERM)",
652663
"previousPrimaryUID", lastFailoverUID,
653664
"currentPrimaryUID", currentPrimaryUID,

0 commit comments

Comments
 (0)