From e0df9dea0c9abfd19e61a16227a3093dcd98ae33 Mon Sep 17 00:00:00 2001 From: Dmitrii Dolgov <9erthalion6@gmail.com> Date: Wed, 4 Mar 2020 16:07:22 +0100 Subject: [PATCH] Sync in case of missing deployment If nothing changed we still need to try to sync and test if the deployment is there. Otherwise it could be deleted, and operator will not notice. --- pkg/cluster/sync.go | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/pkg/cluster/sync.go b/pkg/cluster/sync.go index 307f703ee..4a38a7e77 100644 --- a/pkg/cluster/sync.go +++ b/pkg/cluster/sync.go @@ -2,7 +2,6 @@ package cluster import ( "fmt" - "reflect" batchv1beta1 "k8s.io/api/batch/v1beta1" v1 "k8s.io/api/core/v1" @@ -608,29 +607,12 @@ func (c *Cluster) syncConnectionPool(oldSpec, newSpec *acidv1.Postgresql) error newNeedConnPool := c.needConnectionPoolWorker(&newSpec.Spec) oldNeedConnPool := c.needConnectionPoolWorker(&oldSpec.Spec) - if oldNeedConnPool && newNeedConnPool { - // sync in case of differences, or if no resources present - oldPool := oldSpec.Spec.ConnectionPool - newPool := newSpec.Spec.ConnectionPool - - if c.ConnectionPool == nil || - c.ConnectionPool.Deployment == nil || - c.ConnectionPool.Service == nil || - !reflect.DeepEqual(oldPool, newPool) { - - c.logger.Debug("syncing connection pool") - - if err := c.syncConnectionPoolWorker(oldSpec, newSpec); err != nil { - c.logger.Errorf("could not sync connection pool: %v", err) - return err - } - } else { - c.logger.Debug("No connection pool sync") - } - } - - if !oldNeedConnPool && newNeedConnPool { - // sync to create everything + if newNeedConnPool { + // Try to sync in any case. If we didn't needed connection pool before, + // it means we want to create it. If it was already present, still sync + // since it could happen that there is no difference in specs, and all + // the resources are remembered, but the deployment was manualy deleted + // in between c.logger.Debug("syncing connection pool") if err := c.syncConnectionPoolWorker(oldSpec, newSpec); err != nil {