@@ -29,7 +29,6 @@ import (
2929 "k8s.io/apimachinery/pkg/types"
3030 utilruntime "k8s.io/apimachinery/pkg/util/runtime"
3131 "k8s.io/apimachinery/pkg/util/uuid"
32- "k8s.io/apimachinery/pkg/util/wait"
3332 "k8s.io/client-go/util/workqueue"
3433 "k8s.io/utils/ptr"
3534
@@ -176,28 +175,28 @@ func (c *Controller[request]) Warmup(ctx context.Context) error {
176175}
177176
178177// WaitForWarmupComplete returns true if warmup has completed without error, and false if there was
179- // an error during warmup.
178+ // an error during warmup. If context is cancelled, it returns true.
180179func (c * Controller [request ]) WaitForWarmupComplete (ctx context.Context ) bool {
181- err := wait .PollUntilContextCancel (ctx , syncedPollPeriod , true , func (ctx context.Context ) (bool , error ) {
182- didFinishSync , ok := c .didEventSourcesFinishSyncSuccessfully .Load ().(* bool )
183- if ! ok {
184- return false , errors .New ("unexpected error: didEventSourcesFinishSync is not a bool pointer" )
185- }
186-
187- if didFinishSync == nil {
188- // event sources not finished syncing
189- return false , nil
190- }
180+ ticker := time .NewTicker (syncedPollPeriod )
181+ defer ticker .Stop ()
182+
183+ for {
184+ select {
185+ case <- ctx .Done ():
186+ return true
187+ case <- ticker .C :
188+ didFinishSync , ok := c .didEventSourcesFinishSyncSuccessfully .Load ().(* bool )
189+ if ! ok {
190+ return false
191+ }
191192
192- if ! * didFinishSync {
193- // event sources finished syncing with an error
194- return true , errors .New ("event sources did not finish syncing successfully" )
193+ if didFinishSync != nil && * didFinishSync {
194+ // event sources finished syncing successfully
195+ return true
196+ }
197+ return false
195198 }
196-
197- return true , nil
198- })
199-
200- return err == nil
199+ }
201200}
202201
203202// Start implements controller.Controller.
0 commit comments