File tree 2 files changed +5
-5
lines changed
2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -171,14 +171,15 @@ func (c *Controller[request]) Start(ctx context.Context) error {
171
171
defer utilruntime .HandleCrash ()
172
172
173
173
// NB(directxman12): launch the sources *before* trying to wait for the
174
- // caches to sync so that they have a chance to register their intendeded
174
+ // caches to sync so that they have a chance to register their intended
175
175
// caches.
176
176
errGroup := & errgroup.Group {}
177
177
for _ , watch := range c .startWatches {
178
178
log := c .LogConstructor (nil ).WithValues ("source" , fmt .Sprintf ("%s" , watch ))
179
179
didStartSyncingSource := & atomic.Bool {}
180
180
errGroup .Go (func () error {
181
- // use a context with timeout for launching sources and syncing caches.
181
+ // Use a timeout for starting and syncing the source to avoid silently
182
+ // blocking startup indefinitely if it doesn't come up.
182
183
sourceStartCtx , cancel := context .WithTimeout (ctx , c .CacheSyncTimeout )
183
184
defer cancel ()
184
185
@@ -220,7 +221,6 @@ func (c *Controller[request]) Start(ctx context.Context) error {
220
221
return err
221
222
}
222
223
223
- // Start the SharedIndexInformer factories to begin populating the SharedIndexInformer caches
224
224
c .LogConstructor (nil ).Info ("Starting Controller" )
225
225
226
226
// All the watches have been started, we can reset the local slice.
Original file line number Diff line number Diff line change @@ -201,7 +201,7 @@ var _ = Describe("controller", func() {
201
201
})
202
202
203
203
It ("should error when Start() is blocking forever" , func () {
204
- ctrl .CacheSyncTimeout = 0
204
+ ctrl .CacheSyncTimeout = time . Second
205
205
206
206
controllerDone := make (chan struct {})
207
207
ctrl .startWatches = []source.TypedSource [reconcile.Request ]{
@@ -304,7 +304,7 @@ var _ = Describe("controller", func() {
304
304
Expect (q ).To (Equal (ctrl .Queue ))
305
305
306
306
started = true
307
- cancel ()
307
+ cancel () // Cancel the context so ctrl.Start() doesn't block forever
308
308
return nil
309
309
})
310
310
Expect (ctrl .Watch (src )).NotTo (HaveOccurred ())
You can’t perform that action at this time.
0 commit comments