add waiting group in the main thread

This commit is contained in:
Murat Kabilov 2017-07-14 18:19:56 +02:00
parent 7a2643386c
commit f326e58456
3 changed files with 2 additions and 7 deletions

View File

@ -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)

View File

@ -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 {

View File

@ -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 {