-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Enable loadbalancer.sticky for ECS #1925
Conversation
Could you fix the build?
|
This PR is the implementation for feature requested on #1522 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! 👍
provider/ecs/ecs.go
Outdated
|
||
func (p *Provider) LoadBalancerMethod(instances []ecsInstance) string { | ||
for instances != nil && len(instances) > 0 { | ||
if label := instances[0].label(types.LabelBackendLoadbalancerMethod); label != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you split in two lines?
provider/ecs/ecs.go
Outdated
@@ -420,6 +432,24 @@ func (p *Provider) getFrontendRule(i ecsInstance) string { | |||
return "Host:" + strings.ToLower(strings.Replace(i.Name, "_", "-", -1)) + "." + p.Domain | |||
} | |||
|
|||
func (p *Provider) LoadBalancerSticky(instances []ecsInstance) string { | |||
for instances != nil && len(instances) > 0 { | |||
if label := instances[0].label(types.LabelBackendLoadbalancerSticky); label != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you split in two lines?
provider/ecs/ecs.go
Outdated
@@ -420,6 +432,24 @@ func (p *Provider) getFrontendRule(i ecsInstance) string { | |||
return "Host:" + strings.ToLower(strings.Replace(i.Name, "_", "-", -1)) + "." + p.Domain | |||
} | |||
|
|||
func (p *Provider) LoadBalancerSticky(instances []ecsInstance) string { | |||
for instances != nil && len(instances) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instances != nil
is not needed
provider/ecs/ecs.go
Outdated
} | ||
|
||
func (p *Provider) LoadBalancerMethod(instances []ecsInstance) string { | ||
for instances != nil && len(instances) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instances != nil
is not needed
provider/ecs/ecs.go
Outdated
@@ -420,6 +432,24 @@ func (p *Provider) getFrontendRule(i ecsInstance) string { | |||
return "Host:" + strings.ToLower(strings.Replace(i.Name, "_", "-", -1)) + "." + p.Domain | |||
} | |||
|
|||
func (p *Provider) getLoadBalancerSticky(instances []ecsInstance) string { | |||
for instances != nil && len(instances) > 0 { | |||
if label := instances[0].label(types.LabelBackendLoadbalancerSticky); label != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you split in two lines?
provider/ecs/ecs.go
Outdated
|
||
func (p *Provider) getLoadBalancerMethod(instances []ecsInstance) string { | ||
for instances != nil && len(instances) > 0 { | ||
if label := instances[0].label(types.LabelBackendLoadbalancerMethod); label != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you split in two lines?
provider/ecs/ecs.go
Outdated
@@ -420,6 +432,24 @@ func (p *Provider) getFrontendRule(i ecsInstance) string { | |||
return "Host:" + strings.ToLower(strings.Replace(i.Name, "_", "-", -1)) + "." + p.Domain | |||
} | |||
|
|||
func (p *Provider) getLoadBalancerSticky(instances []ecsInstance) string { | |||
for instances != nil && len(instances) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instances != nil
is unnecessary.
func ExampleEmptySlice() {
var foo []string
fii := bar()
fmt.Println(foo, fii)
// output: [] []
}
func bar() []string{
return nil
}
provider/ecs/ecs.go
Outdated
} | ||
|
||
func (p *Provider) getLoadBalancerMethod(instances []ecsInstance) string { | ||
for instances != nil && len(instances) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instances != nil
is unnecessary.
func ExampleEmptySlice() {
var foo []string
fii := bar()
fmt.Println(foo, fii)
// output: [] []
}
func bar() []string{
return nil
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the go course. I will fix that asap
provider/ecs/ecs.go
Outdated
@@ -189,10 +191,20 @@ func (p *Provider) loadECSConfig(ctx context.Context, client *awsClient) (*types | |||
|
|||
instances = fun.Filter(p.filterInstance, instances).([]ecsInstance) | |||
|
|||
services := make(map[string][]ecsInstance) | |||
|
|||
for _, i := range instances { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you rename i
to instance
?
I know it's already use but I think i
is an ambiguous name in a for
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👏
7fc5ac8
to
bc19311
Compare
…ancerSticky and getLoadBalancerMethod function
bc19311
to
b61a639
Compare
Description
The goal of this PR is to add support of sticky session for ECS.
Low balancer configuration will be always present with default values:
traefik.backend.loadbalancer.method=wrr
traefik.backend.loadbalancer.sticky=false
To override these values you just to add labels
Fixes #1522