Backward compatibility for sticky
This commit is contained in:
parent
3afd6024b5
commit
08503655d9
22 changed files with 140 additions and 260 deletions
|
@ -248,13 +248,15 @@ func (p *Provider) loadIngresses(k8sClient Client) (*types.Configuration, error)
|
|||
templateObjects.Backends[r.Host+pa.Path].LoadBalancer.Method = "drr"
|
||||
}
|
||||
|
||||
if len(service.Annotations[types.LabelBackendLoadbalancerSticky]) > 0 {
|
||||
if sticky := service.Annotations[types.LabelBackendLoadbalancerSticky]; len(sticky) > 0 {
|
||||
log.Warnf("Deprecated configuration found: %s. Please use %s.", types.LabelBackendLoadbalancerSticky, types.LabelBackendLoadbalancerStickiness)
|
||||
templateObjects.Backends[r.Host+pa.Path].LoadBalancer.Sticky = strings.EqualFold(strings.TrimSpace(sticky), "true")
|
||||
}
|
||||
|
||||
if service.Annotations[types.LabelBackendLoadbalancerSticky] == "true" || service.Annotations[types.LabelBackendLoadbalancerStickiness] == "true" {
|
||||
templateObjects.Backends[r.Host+pa.Path].LoadBalancer.Stickiness = &types.Stickiness{
|
||||
CookieName: r.Host + pa.Path,
|
||||
if service.Annotations[types.LabelBackendLoadbalancerStickiness] == "true" {
|
||||
templateObjects.Backends[r.Host+pa.Path].LoadBalancer.Stickiness = &types.Stickiness{}
|
||||
if cookieName := service.Annotations[types.LabelBackendLoadbalancerStickinessCookieName]; len(cookieName) > 0 {
|
||||
templateObjects.Backends[r.Host+pa.Path].LoadBalancer.Stickiness.CookieName = cookieName
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1325,9 +1325,7 @@ func TestServiceAnnotations(t *testing.T) {
|
|||
CircuitBreaker: nil,
|
||||
LoadBalancer: &types.LoadBalancer{
|
||||
Method: "wrr",
|
||||
Stickiness: &types.Stickiness{
|
||||
CookieName: "bar",
|
||||
},
|
||||
Sticky: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1356,7 +1354,7 @@ func TestServiceAnnotations(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
assert.Equal(t, expected, actual)
|
||||
assert.EqualValues(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestIngressAnnotations(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue