Address review, add ConnectionPool init for sync
This commit is contained in:
parent
a9d02bacc4
commit
515bb2dfad
|
|
@ -152,7 +152,7 @@ These parameters are grouped directly under the `spec` key in the manifest.
|
||||||
* enableConnectionPool
|
* enableConnectionPool
|
||||||
Tells the operator to create a connection pool with a database. If this
|
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
|
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
|
## Postgres parameters
|
||||||
|
|
||||||
|
|
@ -376,7 +376,7 @@ present.
|
||||||
How many instances of connection pool to create.
|
How many instances of connection pool to create.
|
||||||
|
|
||||||
* **mode**
|
* **mode**
|
||||||
In which mode to run connection pool, transaction or section.
|
In which mode to run connection pool, transaction or session.
|
||||||
|
|
||||||
* **schema**
|
* **schema**
|
||||||
Schema to create for credentials lookup function.
|
Schema to create for credentials lookup function.
|
||||||
|
|
|
||||||
|
|
@ -613,7 +613,7 @@ operator being able to provide some reasonable defaults.
|
||||||
Docker image to use for connection pool deployment.
|
Docker image to use for connection pool deployment.
|
||||||
|
|
||||||
* **connection_pool_mode**
|
* **connection_pool_mode**
|
||||||
Default pool mode, sesssion or transaction.
|
Default pool mode, session or transaction.
|
||||||
|
|
||||||
* **connection_pool_default_cpu_request**
|
* **connection_pool_default_cpu_request**
|
||||||
**connection_pool_default_memory_reques**
|
**connection_pool_default_memory_reques**
|
||||||
|
|
|
||||||
|
|
@ -468,7 +468,7 @@ spec:
|
||||||
```
|
```
|
||||||
|
|
||||||
This will tell the operator to create a connection pool with default
|
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
|
`{cluster-name}-pooler`. In most of the cases provided default configuration
|
||||||
should be good enough.
|
should be good enough.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1217,7 +1217,8 @@ func (c *Cluster) needSyncConnPoolDeployments(oldSpec, newSpec *acidv1.Connectio
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.logger.Infof("Cannot get diff, do not do anything, %+v", err)
|
c.logger.Infof("Cannot get diff, do not do anything, %+v", err)
|
||||||
return false, reasons
|
return false, reasons
|
||||||
} else {
|
}
|
||||||
|
|
||||||
if len(changelog) > 0 {
|
if len(changelog) > 0 {
|
||||||
sync = true
|
sync = true
|
||||||
}
|
}
|
||||||
|
|
@ -1227,7 +1228,6 @@ func (c *Cluster) needSyncConnPoolDeployments(oldSpec, newSpec *acidv1.Connectio
|
||||||
change.Type, change.Path, change.From, change.To)
|
change.Type, change.Path, change.From, change.To)
|
||||||
reasons = append(reasons, msg)
|
reasons = append(reasons, msg)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return sync, reasons
|
return sync, reasons
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1860,6 +1860,16 @@ func (c *Cluster) ownerReferences() []metav1.OwnerReference {
|
||||||
func (c *Cluster) generateConnPoolDeployment(spec *acidv1.PostgresSpec) (
|
func (c *Cluster) generateConnPoolDeployment(spec *acidv1.PostgresSpec) (
|
||||||
*appsv1.Deployment, error) {
|
*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)
|
podTemplate, err := c.generateConnPoolPodTemplate(spec)
|
||||||
numberOfInstances := spec.ConnectionPool.NumberOfInstances
|
numberOfInstances := spec.ConnectionPool.NumberOfInstances
|
||||||
if numberOfInstances == nil {
|
if numberOfInstances == nil {
|
||||||
|
|
@ -1895,6 +1905,17 @@ func (c *Cluster) generateConnPoolDeployment(spec *acidv1.PostgresSpec) (
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cluster) generateConnPoolService(spec *acidv1.PostgresSpec) *v1.Service {
|
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{
|
serviceSpec := v1.ServiceSpec{
|
||||||
Ports: []v1.ServicePort{
|
Ports: []v1.ServicePort{
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -864,7 +864,7 @@ func (c *Cluster) updateConnPoolDeployment(oldDeploymentSpec, newDeployment *app
|
||||||
}
|
}
|
||||||
|
|
||||||
// An update probably requires RetryOnConflict, but since only one operator
|
// 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.
|
// minimal.
|
||||||
deployment, err := c.KubeClient.
|
deployment, err := c.KubeClient.
|
||||||
Deployments(c.ConnectionPool.Deployment.Namespace).
|
Deployments(c.ConnectionPool.Deployment.Namespace).
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue