From c5e0b43a3660211d0ac40ec1cc905d9d65a763e7 Mon Sep 17 00:00:00 2001 From: Mitch Murphy Date: Fri, 5 Jun 2026 14:35:57 -0400 Subject: [PATCH] refactor(pooler): extract connectionPoolerConfigMapName helper --- pkg/cluster/connection_pooler.go | 8 ++++---- pkg/cluster/pgbouncer_config.go | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pkg/cluster/connection_pooler.go b/pkg/cluster/connection_pooler.go index 9f0525ef1..9198f3c68 100644 --- a/pkg/cluster/connection_pooler.go +++ b/pkg/cluster/connection_pooler.go @@ -471,7 +471,7 @@ func (c *Cluster) generateConnectionPoolerPodTemplate(role PostgresRole) ( // container command/args (e.g. for images like the Chainguard FIPS pgbouncer // whose entrypoint is the bare binary with no config-rendering wrapper). if c.OpConfig.ConnectionPooler.GenerateConfig { - configVolumeName := fmt.Sprintf("%s-config", c.connectionPoolerName(role)) + configVolumeName := c.connectionPoolerConfigMapName(role) poolerVolumes = append(poolerVolumes, v1.Volume{ Name: configVolumeName, VolumeSource: v1.VolumeSource{ @@ -511,9 +511,9 @@ func (c *Cluster) generateConnectionPoolerPodTemplate(role PostgresRole) ( securityContext.FSGroup = effectiveFSGroup } - podAnnotations, annErr := c.connectionPoolerPodAnnotations(role) - if annErr != nil { - return nil, annErr + podAnnotations, err := c.connectionPoolerPodAnnotations(role) + if err != nil { + return nil, err } podTemplate := &v1.PodTemplateSpec{ diff --git a/pkg/cluster/pgbouncer_config.go b/pkg/cluster/pgbouncer_config.go index eef6e0859..bfcac2dcd 100644 --- a/pkg/cluster/pgbouncer_config.go +++ b/pkg/cluster/pgbouncer_config.go @@ -147,6 +147,12 @@ func (c *Cluster) connectionPoolerConfigChecksum(role PostgresRole) (string, err return fmt.Sprintf("%x", sum), nil } +// connectionPoolerConfigMapName returns the name of the operator-generated +// pgbouncer config map for the given role. +func (c *Cluster) connectionPoolerConfigMapName(role PostgresRole) string { + return fmt.Sprintf("%s-config", c.connectionPoolerName(role)) +} + // generateConnectionPoolerConfigMap builds the operator-owned ConfigMap holding // the rendered pgbouncer.ini for the given role. func (c *Cluster) generateConnectionPoolerConfigMap(role PostgresRole) (*v1.ConfigMap, error) { @@ -156,7 +162,7 @@ func (c *Cluster) generateConnectionPoolerConfigMap(role PostgresRole) (*v1.Conf } return &v1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("%s-config", c.connectionPoolerName(role)), + Name: c.connectionPoolerConfigMapName(role), Namespace: c.Namespace, Labels: c.connectionPoolerLabels(role, true).MatchLabels, Annotations: c.annotationsSet(nil),