diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index f346454ac..339ea183b 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -63,17 +63,17 @@ func New(controllerConfig *Config, operatorConfig *config.Config) *Controller { } func (c *Controller) Run(stopCh <-chan struct{}, wg *sync.WaitGroup) { - defer wg.Done() - wg.Add(1) c.initController() + wg.Add(4) go c.runPodInformer(stopCh, wg) go c.runPostgresqlInformer(stopCh, wg) go c.podEventsDispatcher(stopCh, wg) go c.clusterResync(stopCh, wg) for i := range c.clusterEventQueues { + wg.Add(1) go c.processClusterEventsQueue(stopCh, i, wg) } @@ -145,7 +145,6 @@ func (c *Controller) initController() { func (c *Controller) runPodInformer(stopCh <-chan struct{}, wg *sync.WaitGroup) { defer wg.Done() - wg.Add(1) go c.podInformer.Run(stopCh) @@ -154,7 +153,6 @@ func (c *Controller) runPodInformer(stopCh <-chan struct{}, wg *sync.WaitGroup) func (c *Controller) runPostgresqlInformer(stopCh <-chan struct{}, wg *sync.WaitGroup) { defer wg.Done() - wg.Add(1) go c.postgresqlInformer.Run(stopCh) diff --git a/pkg/controller/pod.go b/pkg/controller/pod.go index ba44625b6..2f37883f8 100644 --- a/pkg/controller/pod.go +++ b/pkg/controller/pod.go @@ -116,7 +116,6 @@ func (c *Controller) podDelete(obj interface{}) { func (c *Controller) podEventsDispatcher(stopCh <-chan struct{}, wg *sync.WaitGroup) { defer wg.Done() - wg.Add(1) c.logger.Debugln("Watching all pod events") for { diff --git a/pkg/controller/postgresql.go b/pkg/controller/postgresql.go index d01d53eb9..1c2a23872 100644 --- a/pkg/controller/postgresql.go +++ b/pkg/controller/postgresql.go @@ -23,7 +23,6 @@ import ( func (c *Controller) clusterResync(stopCh <-chan struct{}, wg *sync.WaitGroup) { defer wg.Done() - wg.Add(1) ticker := time.NewTicker(c.opConfig.ResyncPeriod) for { @@ -208,7 +207,6 @@ func (c *Controller) processEvent(obj interface{}) error { func (c *Controller) processClusterEventsQueue(stopCh <-chan struct{}, idx int, wg *sync.WaitGroup) { defer wg.Done() - wg.Add(1) go func() { if _, err := c.clusterEventQueues[idx].Pop(cache.PopProcessFunc(c.processEvent)); err != nil {