Skip to content

Commit

Permalink
fix(runner): don't spam logs with warnings when first connecting (#522)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas authored Oct 26, 2023
1 parent 44e1bcf commit f60aba9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
14 changes: 5 additions & 9 deletions backend/common/rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func RetryStreamingClientStream[Req, Resp any](
rpc func(context.Context) *connect.ClientStreamForClient[Req, Resp],
handler func(ctx context.Context, send func(*Req) error) error,
) {
logLevel := log.Debug
errored := false
logger := log.FromContext(ctx)
for {
Expand All @@ -155,24 +156,19 @@ func RetryStreamingClientStream[Req, Resp any](
logger.Infof("Stream recovered")
errored = false
}
select {
case <-ctx.Done():
if _, ok := <-ctx.Done(); ok {
return
default:
}
retry.Reset()
logLevel = log.Warn
}
_, _ = stream.CloseAndReceive()

errored = true
delay := retry.Duration()
logger.Warnf("Stream handler failed, retrying in %s: %s", delay, err)
select {
case <-ctx.Done():
logger.Logf(logLevel, "Stream handler failed, retrying in %s: %s", delay, err)
if _, ok := <-ctx.Done(); ok {
return

case <-time.After(delay):
}

}
}
3 changes: 1 addition & 2 deletions backend/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,8 @@ func (s *Service) registrationLoop(ctx context.Context, send func(request *ftlv1
Error: errPtr,
})
if err != nil {
logger.Errorf(err, "failed to register with Controller")
s.registrationFailure.Store(types.Some(err))
return errors.WithStack(err)
return errors.Wrap(err, "failed to register with Controller")
}
s.registrationFailure.Store(types.None[error]())

Expand Down

0 comments on commit f60aba9

Please sign in to comment.