Prevent error logging when TCP WRR pool is empty
This commit is contained in:
parent
0eb0a15aa1
commit
e7dc097901
1 changed files with 7 additions and 3 deletions
|
@ -7,6 +7,8 @@ import (
|
||||||
"github.com/traefik/traefik/v2/pkg/log"
|
"github.com/traefik/traefik/v2/pkg/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var errNoServersInPool = errors.New("no servers in the pool")
|
||||||
|
|
||||||
type server struct {
|
type server struct {
|
||||||
Handler
|
Handler
|
||||||
weight int
|
weight int
|
||||||
|
@ -34,8 +36,10 @@ func (b *WRRLoadBalancer) ServeTCP(conn WriteCloser) {
|
||||||
b.lock.Unlock()
|
b.lock.Unlock()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithoutContext().Errorf("Error during load balancing: %v", err)
|
if !errors.Is(err, errNoServersInPool) {
|
||||||
conn.Close()
|
log.WithoutContext().Errorf("Error during load balancing: %v", err)
|
||||||
|
}
|
||||||
|
_ = conn.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +95,7 @@ func gcd(a, b int) int {
|
||||||
|
|
||||||
func (b *WRRLoadBalancer) next() (Handler, error) {
|
func (b *WRRLoadBalancer) next() (Handler, error) {
|
||||||
if len(b.servers) == 0 {
|
if len(b.servers) == 0 {
|
||||||
return nil, errors.New("no servers in the pool")
|
return nil, errNoServersInPool
|
||||||
}
|
}
|
||||||
|
|
||||||
// The algo below may look messy, but is actually very simple
|
// The algo below may look messy, but is actually very simple
|
||||||
|
|
Loading…
Reference in a new issue