Skip to content

Commit bed406c

Browse files
mustard-mhroboquat
authored andcommitted
[supervisor] fix backoff forever with ctx cancel
1 parent 7c31148 commit bed406c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

components/supervisor/pkg/serverapi/publicapi.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,12 @@ func (s *Service) publicAPIInstanceUpdate(ctx context.Context, workspaceID strin
304304
log.WithError(err).Info("backoff failed to get workspace service client of PublicAPI, try again")
305305
}
306306
return resp, err
307-
}, connBackoff)
307+
}, backoff.WithContext(ConnBackoff, ctx))
308308
if err != nil {
309+
// we don't care about ctx canceled
310+
if ctx.Err() != nil {
311+
return
312+
}
309313
log.WithField("method", "StreamWorkspaceStatus").WithError(err).Error("failed to call PublicAPI")
310314
errChan <- err
311315
return
@@ -334,8 +338,12 @@ func (s *Service) serverInstanceUpdate(ctx context.Context, instanceID string, u
334338
log.WithError(err).Info("backoff failed to listen to serverAPI instanceUpdates, try again")
335339
}
336340
return ch, err
337-
}, connBackoff)
341+
}, backoff.WithContext(ConnBackoff, ctx))
338342
if err != nil {
343+
// we don't care about ctx canceled
344+
if ctx.Err() != nil {
345+
return
346+
}
339347
log.WithField("method", "InstanceUpdates").WithError(err).Error("failed to call serverAPI")
340348
errChan <- err
341349
return
@@ -350,7 +358,7 @@ func (s *Service) serverInstanceUpdate(ctx context.Context, instanceID string, u
350358
errChan <- io.EOF
351359
}
352360

353-
var connBackoff = &backoff.ExponentialBackOff{
361+
var ConnBackoff = &backoff.ExponentialBackOff{
354362
InitialInterval: 2 * time.Second,
355363
RandomizationFactor: 0.5,
356364
Multiplier: 1.5,

0 commit comments

Comments
 (0)