Skip to content

Commit

Permalink
fix: remove deprecated 'wait' function usage and catch context cancel…
Browse files Browse the repository at this point in the history
…ed errors for conditional informers (#155)
  • Loading branch information
saumas authored Jan 24, 2024
1 parent b9f9f05 commit 2c016d4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/services/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ func (c *Controller) Run(ctx context.Context) error {

func (c *Controller) startConditionalInformersWithWatcher(ctx context.Context, conditionalInformers []conditionalInformer) {
tryConditionalInformers := conditionalInformers
if err := wait.PollImmediateInfiniteWithContext(ctx, time.Minute*2, func(ctx context.Context) (done bool, err error) {

if err := wait.PollUntilContextCancel(ctx, 2*time.Minute, true, func(ctx context.Context) (done bool, err error) {
apiResourceLists := fetchAPIResourceLists(c.discovery, c.log)
if apiResourceLists == nil {
return false, nil
Expand Down Expand Up @@ -283,8 +284,8 @@ func (c *Controller) startConditionalInformersWithWatcher(ctx context.Context, c
return false, nil
}
return true, nil
}); err != nil {
c.log.Warnf("Error when waiting for server resources: %v", err.Error())
}); err != nil && !errors.Is(err, context.Canceled) {
c.log.Errorf("error when waiting for server resources: %v", err)
}
}

Expand Down

0 comments on commit 2c016d4

Please sign in to comment.