Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runner): don't spam logs with warnings when first connecting #522

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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