diff --git a/docs/reference/cluster_manifest.md b/docs/reference/cluster_manifest.md index 4c5ce2f9c..a66cc169d 100644 --- a/docs/reference/cluster_manifest.md +++ b/docs/reference/cluster_manifest.md @@ -152,7 +152,7 @@ These parameters are grouped directly under the `spec` key in the manifest. * enableConnectionPool Tells the operator to create a connection pool with a database. If this field is true, a connection pool deployment will be created even if - `connectionPool` section is empty. + `connectionPool` section is empty. Optional, not set by default. ## Postgres parameters @@ -376,7 +376,7 @@ present. How many instances of connection pool to create. * **mode** - In which mode to run connection pool, transaction or section. + In which mode to run connection pool, transaction or session. * **schema** Schema to create for credentials lookup function. diff --git a/docs/reference/operator_parameters.md b/docs/reference/operator_parameters.md index 665a4c992..25ad46058 100644 --- a/docs/reference/operator_parameters.md +++ b/docs/reference/operator_parameters.md @@ -613,7 +613,7 @@ operator being able to provide some reasonable defaults. Docker image to use for connection pool deployment. * **connection_pool_mode** - Default pool mode, sesssion or transaction. + Default pool mode, session or transaction. * **connection_pool_default_cpu_request** **connection_pool_default_memory_reques** diff --git a/docs/user.md b/docs/user.md index 64e5b98d1..747b6dbe4 100644 --- a/docs/user.md +++ b/docs/user.md @@ -468,7 +468,7 @@ spec: ``` This will tell the operator to create a connection pool with default -configuration, though which one can access the master via a separate service +configuration, through which one can access the master via a separate service `{cluster-name}-pooler`. In most of the cases provided default configuration should be good enough. diff --git a/pkg/cluster/cluster.go b/pkg/cluster/cluster.go index de70e1477..94400066b 100644 --- a/pkg/cluster/cluster.go +++ b/pkg/cluster/cluster.go @@ -1217,16 +1217,16 @@ func (c *Cluster) needSyncConnPoolDeployments(oldSpec, newSpec *acidv1.Connectio if err != nil { c.logger.Infof("Cannot get diff, do not do anything, %+v", err) return false, reasons - } else { - if len(changelog) > 0 { - sync = true - } + } - for _, change := range changelog { - msg := fmt.Sprintf("%s %+v from %s to %s", - change.Type, change.Path, change.From, change.To) - reasons = append(reasons, msg) - } + if len(changelog) > 0 { + sync = true + } + + for _, change := range changelog { + msg := fmt.Sprintf("%s %+v from %s to %s", + change.Type, change.Path, change.From, change.To) + reasons = append(reasons, msg) } return sync, reasons diff --git a/pkg/cluster/k8sres.go b/pkg/cluster/k8sres.go index 3121691d9..9966f5b55 100644 --- a/pkg/cluster/k8sres.go +++ b/pkg/cluster/k8sres.go @@ -1860,6 +1860,16 @@ func (c *Cluster) ownerReferences() []metav1.OwnerReference { func (c *Cluster) generateConnPoolDeployment(spec *acidv1.PostgresSpec) ( *appsv1.Deployment, error) { + // there are two ways to enable connection pooler, either to specify a + // connectionPool section or enableConnectionPool. In the second case + // spec.connectionPool will be nil, so to make it easier to calculate + // default values, initialize it to an empty structure. It could be done + // anywhere, but here is the earliest common entry point between sync and + // create code, so init here. + if spec.ConnectionPool == nil { + spec.ConnectionPool = &acidv1.ConnectionPool{} + } + podTemplate, err := c.generateConnPoolPodTemplate(spec) numberOfInstances := spec.ConnectionPool.NumberOfInstances if numberOfInstances == nil { @@ -1895,6 +1905,17 @@ func (c *Cluster) generateConnPoolDeployment(spec *acidv1.PostgresSpec) ( } func (c *Cluster) generateConnPoolService(spec *acidv1.PostgresSpec) *v1.Service { + + // there are two ways to enable connection pooler, either to specify a + // connectionPool section or enableConnectionPool. In the second case + // spec.connectionPool will be nil, so to make it easier to calculate + // default values, initialize it to an empty structure. It could be done + // anywhere, but here is the earliest common entry point between sync and + // create code, so init here. + if spec.ConnectionPool == nil { + spec.ConnectionPool = &acidv1.ConnectionPool{} + } + serviceSpec := v1.ServiceSpec{ Ports: []v1.ServicePort{ { diff --git a/pkg/cluster/resources.go b/pkg/cluster/resources.go index 46be0af4b..6b0648680 100644 --- a/pkg/cluster/resources.go +++ b/pkg/cluster/resources.go @@ -864,7 +864,7 @@ func (c *Cluster) updateConnPoolDeployment(oldDeploymentSpec, newDeployment *app } // An update probably requires RetryOnConflict, but since only one operator - // worker at one time will try to update it changes of conflicts are + // worker at one time will try to update it chances of conflicts are // minimal. deployment, err := c.KubeClient. Deployments(c.ConnectionPool.Deployment.Namespace).