@@ -29,7 +29,6 @@ import (
29
29
"k8s.io/apimachinery/pkg/types"
30
30
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
31
31
"k8s.io/apimachinery/pkg/util/uuid"
32
- "k8s.io/apimachinery/pkg/util/wait"
33
32
"k8s.io/client-go/util/workqueue"
34
33
"k8s.io/utils/ptr"
35
34
@@ -176,28 +175,28 @@ func (c *Controller[request]) Warmup(ctx context.Context) error {
176
175
}
177
176
178
177
// 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.
180
179
func (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
+ }
191
192
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
195
198
}
196
-
197
- return true , nil
198
- })
199
-
200
- return err == nil
199
+ }
201
200
}
202
201
203
202
// Start implements controller.Controller.
0 commit comments