Skip to content

Commit

Permalink
client: update retryable connection error logs to warning (#150)
Browse files Browse the repository at this point in the history
Also updates yamux to avoid logging retryable errors as error logs
within yamux.
  • Loading branch information
andydunstall authored Aug 10, 2024
1 parent e5dd9e3 commit e37ae01
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
8 changes: 1 addition & 7 deletions client/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import (
"context"
"errors"
"fmt"
"io"
"net"
"strings"

"github.com/andydunstall/yamux"
"go.uber.org/zap"
Expand Down Expand Up @@ -81,11 +79,7 @@ func (l *listener) AcceptWithContext(ctx context.Context) (net.Conn, error) {
return nil, ErrClosed
}

if err != io.EOF && !strings.Contains(err.Error(), "closed") && !strings.Contains(err.Error(), "reset by peer") {
l.logger.Error("failed to accept conn", zap.Error(err))
} else {
l.logger.Warn("disconnected; reconnecting")
}
l.logger.Warn("disconnected; reconnecting", zap.Error(err))

if err := l.connect(l.closeCtx); err != nil {
return nil, fmt.Errorf("connect: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion client/upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (u *Upstream) connect(ctx context.Context, endpointID string) (*yamux.Sessi
return nil, err
}

u.logger().Error(
u.logger().Warn(
"connect failed; retrying",
zap.String("endpoint-id", endpointID),
zap.String("url", url),
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/andydunstall/piko
go 1.22

require (
github.com/andydunstall/yamux v0.1.3
github.com/andydunstall/yamux v0.1.4
github.com/gin-gonic/gin v1.10.0
github.com/goccy/go-yaml v1.12.0
github.com/golang-jwt/jwt/v5 v5.2.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/andydunstall/yamux v0.1.3 h1:lTNkGpbbVuAttKhnn5W290a1yMWVav3GnijrcHhjuKU=
github.com/andydunstall/yamux v0.1.3/go.mod h1:v4C9l2I4bhYdww+IVgjO0o5rVzxXbx2nneuFDHvyM28=
github.com/andydunstall/yamux v0.1.4 h1:VrcjPsG5gUb8QnUFdHXoJnmFfncnu0wbeEjekZs4M78=
github.com/andydunstall/yamux v0.1.4/go.mod h1:v4C9l2I4bhYdww+IVgjO0o5rVzxXbx2nneuFDHvyM28=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
Expand Down

0 comments on commit e37ae01

Please sign in to comment.