Skip to content

Commit

Permalink
[supervisor] fix backoff forever with ctx cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
mustard-mh authored and roboquat committed Jan 13, 2023
1 parent 7c31148 commit bed406c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions components/supervisor/pkg/serverapi/publicapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,12 @@ func (s *Service) publicAPIInstanceUpdate(ctx context.Context, workspaceID strin
log.WithError(err).Info("backoff failed to get workspace service client of PublicAPI, try again")
}
return resp, err
}, connBackoff)
}, backoff.WithContext(ConnBackoff, ctx))
if err != nil {
// we don't care about ctx canceled
if ctx.Err() != nil {
return
}
log.WithField("method", "StreamWorkspaceStatus").WithError(err).Error("failed to call PublicAPI")
errChan <- err
return
Expand Down Expand Up @@ -334,8 +338,12 @@ func (s *Service) serverInstanceUpdate(ctx context.Context, instanceID string, u
log.WithError(err).Info("backoff failed to listen to serverAPI instanceUpdates, try again")
}
return ch, err
}, connBackoff)
}, backoff.WithContext(ConnBackoff, ctx))
if err != nil {
// we don't care about ctx canceled
if ctx.Err() != nil {
return
}
log.WithField("method", "InstanceUpdates").WithError(err).Error("failed to call serverAPI")
errChan <- err
return
Expand All @@ -350,7 +358,7 @@ func (s *Service) serverInstanceUpdate(ctx context.Context, instanceID string, u
errChan <- io.EOF
}

var connBackoff = &backoff.ExponentialBackOff{
var ConnBackoff = &backoff.ExponentialBackOff{
InitialInterval: 2 * time.Second,
RandomizationFactor: 0.5,
Multiplier: 1.5,
Expand Down

0 comments on commit bed406c

Please sign in to comment.