slene commented on a change in pull request #453:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/453#discussion_r634320904



##########
File path: pkg/ingress/controller.go
##########
@@ -317,30 +325,47 @@ election:
 }
 
 func (c *Controller) run(ctx context.Context) {
-       log.Infow("controller now is running as leader",
+       log.Infow("controller tries to leading ...",
                zap.String("namespace", c.namespace),
                zap.String("pod", c.name),
        )
+
+       var cancelFunc context.CancelFunc

Review comment:
       
   
   ```
   ...
   election:
        curCtx, cancel := context.WithCancel(rootCtx)
        c.leaderContextCancelFunc = cancel
        elector.Run(curCtx)
        select {
        case <-rootCtx.Done():
                return nil
        default:
                goto election
        }
   ...
   ```
   ```
   func (c *Controller) run(ctx context.Context) {
   ...
        defer c.leaderContextCancelFunc()
   ...
        <-ctx.Done()
        c.wg.Wait()
   }
   ```
   
   Not, you mean use one c.leaderContextCancelFunc to control the run context ? 
It is not enough.
   I think the code should wait for all goroutine to exit in c.run before 
executing the next election.
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to