Fix race between err chan send and re-queue
Signed-off-by: Monis Khan <mok@vmware.com>
This commit is contained in:
parent
32b038c639
commit
7b1ecf79a6
@ -378,16 +378,18 @@ func (c *impersonatorConfigController) ensureImpersonatorIsStarted(syncCtx contr
|
||||
}
|
||||
|
||||
c.serverStopCh = make(chan struct{})
|
||||
c.errorCh = make(chan error)
|
||||
// use a buffered channel so that startImpersonatorFunc can send
|
||||
// on it without coordinating with the main controller go routine
|
||||
c.errorCh = make(chan error, 1)
|
||||
|
||||
// startImpersonatorFunc will block until the server shuts down (or fails to start), so run it in the background.
|
||||
go func() {
|
||||
startOrStopErr := startImpersonatorFunc(c.serverStopCh)
|
||||
// The server has stopped, so enqueue ourselves for another sync, so we can
|
||||
// try to start the server again as quickly as possible.
|
||||
syncCtx.Queue.AddRateLimited(syncCtx.Key) // TODO this a race because the main controller go routine could run and complete before we send on the err chan
|
||||
// The server has stopped, so enqueue ourselves for another sync,
|
||||
// so we can try to start the server again as quickly as possible.
|
||||
defer syncCtx.Queue.AddRateLimited(syncCtx.Key)
|
||||
|
||||
// Forward any errors returned by startImpersonatorFunc on the errorCh.
|
||||
c.errorCh <- startOrStopErr
|
||||
c.errorCh <- startImpersonatorFunc(c.serverStopCh)
|
||||
}()
|
||||
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user