Address review, add ConnectionPool init for sync

This commit is contained in:
Dmitrii Dolgov
2020-02-17 13:07:40 +01:00
parent a9d02bacc4
commit 515bb2dfad
6 changed files with 35 additions and 14 deletions
+9 -9
View File
@@ -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
+21
View File
@@ -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{
{
+1 -1
View File
@@ -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).