handle context in process loop

Kubernetes-commit: f67d30b3529ea970dd5fd069eaddfc7f61d74169
This commit is contained in:
Keisuke Ishigami 2025-05-29 00:34:43 +09:00 committed by Kubernetes Publisher
parent 660181394a
commit 03728c1ebe

View File

@ -204,13 +204,15 @@ func (c *controller) LastSyncResourceVersion() string {
// concurrently.
func (c *controller) processLoop(ctx context.Context) {
for {
// TODO: Plumb through the ctx so that this can
// actually exit when the controller is stopped. Or just give up on this stuff
// ever being stoppable.
_, err := c.config.Queue.Pop(PopProcessFunc(c.config.Process))
if err != nil {
if err == ErrFIFOClosed {
return
select {
case <-ctx.Done():
return
default:
_, err := c.config.Queue.Pop(PopProcessFunc(c.config.Process))
if err != nil {
if err == ErrFIFOClosed {
return
}
}
}
}