Skip to content

Commit c58ea29

Browse files
committed
address comments
Signed-off-by: Eric Pickard <piceri@github.com>
1 parent 32d1f4d commit c58ea29

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

internal/controller/controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@ func (c *Controller) Run(ctx context.Context, workers int) error {
339339
c.cronJobInformer.HasSynced,
340340
) {
341341
cancel()
342+
if ctx.Err() != nil {
343+
return fmt.Errorf("cache sync interrupted: %w", ctx.Err())
344+
}
342345
return errors.New("timed out waiting for caches to sync - please ensure deployment tracker has the correct kubernetes permissions")
343346
}
344347
cancel()

internal/controller/controller_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ func TestRun_InformerSyncTimeout(t *testing.T) {
545545
fakeClient.PrependReactor("list", "*", func(_ k8stesting.Action) (bool, runtime.Object, error) {
546546
// Block until the test completes.
547547
<-blocker
548-
return true, nil, nil
548+
return true, nil, fmt.Errorf("fail")
549549
})
550550
defer close(blocker)
551551

@@ -569,9 +569,12 @@ func TestRun_InformerSyncTimeout(t *testing.T) {
569569
informerSyncTimeout: 2 * time.Second,
570570
}
571571

572+
ctx, cancel := context.WithCancel(context.Background())
573+
defer cancel()
574+
572575
errCh := make(chan error, 1)
573576
go func() {
574-
errCh <- ctrl.Run(context.Background(), 1)
577+
errCh <- ctrl.Run(ctx, 1)
575578
}()
576579

577580
select {

0 commit comments

Comments
 (0)