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.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.
|
// startImpersonatorFunc will block until the server shuts down (or fails to start), so run it in the background.
|
||||||
go func() {
|
go func() {
|
||||||
startOrStopErr := startImpersonatorFunc(c.serverStopCh)
|
// The server has stopped, so enqueue ourselves for another sync,
|
||||||
// The server has stopped, so enqueue ourselves for another sync, so we can
|
// so we can try to start the server again as quickly as possible.
|
||||||
// try to start the server again as quickly as possible.
|
defer syncCtx.Queue.AddRateLimited(syncCtx.Key)
|
||||||
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
|
|
||||||
// Forward any errors returned by startImpersonatorFunc on the errorCh.
|
// Forward any errors returned by startImpersonatorFunc on the errorCh.
|
||||||
c.errorCh <- startOrStopErr
|
c.errorCh <- startImpersonatorFunc(c.serverStopCh)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user