Enhance Load-balancing method validation log.
This commit is contained in:
parent
0ba28bbc8b
commit
bc26d9f0de
2 changed files with 14 additions and 9 deletions
|
@ -1438,7 +1438,7 @@ func configureBackends(backends map[string]*types.Backend) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Debugf("Validation of load balancer method for backend %s failed: %s. Using default method wrr.", backendName, err)
|
log.Debugf("Backend %s: %v", backendName, err)
|
||||||
|
|
||||||
var stickiness *types.Stickiness
|
var stickiness *types.Stickiness
|
||||||
if backend.LoadBalancer != nil {
|
if backend.LoadBalancer != nil {
|
||||||
|
|
|
@ -211,16 +211,21 @@ var loadBalancerMethodNames = []string{
|
||||||
|
|
||||||
// NewLoadBalancerMethod create a new LoadBalancerMethod from a given LoadBalancer.
|
// NewLoadBalancerMethod create a new LoadBalancerMethod from a given LoadBalancer.
|
||||||
func NewLoadBalancerMethod(loadBalancer *LoadBalancer) (LoadBalancerMethod, error) {
|
func NewLoadBalancerMethod(loadBalancer *LoadBalancer) (LoadBalancerMethod, error) {
|
||||||
var method string
|
if loadBalancer == nil {
|
||||||
if loadBalancer != nil {
|
return Wrr, errors.New("no load-balancer defined, fallback to 'wrr' method")
|
||||||
method = loadBalancer.Method
|
}
|
||||||
for i, name := range loadBalancerMethodNames {
|
|
||||||
if strings.EqualFold(name, method) {
|
if len(loadBalancer.Method) == 0 {
|
||||||
return LoadBalancerMethod(i), nil
|
return Wrr, errors.New("no load-balancing method defined, fallback to 'wrr' method")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for i, name := range loadBalancerMethodNames {
|
||||||
|
if strings.EqualFold(name, loadBalancer.Method) {
|
||||||
|
return LoadBalancerMethod(i), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Wrr, fmt.Errorf("invalid load-balancing method '%s'", method)
|
|
||||||
|
return Wrr, fmt.Errorf("invalid load-balancing method %q, fallback to 'wrr' method", loadBalancer.Method)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configurations is for currentConfigurations Map
|
// Configurations is for currentConfigurations Map
|
||||||
|
|
Loading…
Reference in a new issue