@@ -54,29 +54,15 @@ func newRunnables(errChan chan error) *runnables {
54
54
// The runnables added before Start are started when Start is called.
55
55
// The runnables added after Start are started directly.
56
56
func (r * runnables ) Add (fn Runnable , ready runnableCheck ) error {
57
+ if ready == nil {
58
+ // If we don't have a readiness check, always return true.
59
+ ready = func (_ context.Context ) bool { return true }
60
+ }
61
+
57
62
switch runnable := fn .(type ) {
58
63
case hasCache :
59
64
return r .Caches .Add (fn , func (ctx context.Context ) bool {
60
- // Run the ready check for the cache a fixed number of times
61
- // backing off a bit; this is to give time to the runnables
62
- // to start up before their health check returns true.
63
- if err := wait .ExponentialBackoffWithContext (ctx , wait.Backoff {
64
- Duration : 10 * time .Millisecond ,
65
- Steps : 10 ,
66
- Factor : 1.0 ,
67
- }, func () (bool , error ) {
68
- for i := 0 ; i < 10 ; i ++ {
69
- <- time .After (time .Duration (i ) * 10 * time .Millisecond )
70
- if ! runnable .GetCache ().WaitForCacheSync (ctx ) {
71
- continue
72
- }
73
- return true , nil
74
- }
75
- return false , nil
76
- }); err != nil {
77
- return false
78
- }
79
- return true
65
+ return ready (ctx ) && runnable .GetCache ().WaitForCacheSync (ctx )
80
66
})
81
67
case * webhook.Server :
82
68
return r .Webhooks .Add (fn , ready )
@@ -259,7 +245,6 @@ func (r *runnableGroup) Add(rn Runnable, ready runnableCheck) error {
259
245
}
260
246
r .stop .RUnlock ()
261
247
262
- // If we don't have a readiness check, always return true.
263
248
if ready == nil {
264
249
ready = func (_ context.Context ) bool { return true }
265
250
}
0 commit comments