Fix Docker integration problems

This commit is contained in:
Owen Marshall 2016-06-08 15:08:03 -04:00 committed by Emile Vauge
parent be5b1fd92b
commit c9d4c5ae3e
No known key found for this signature in database
GPG key ID: D808B4C167352E59
3 changed files with 15 additions and 11 deletions

View file

@ -252,6 +252,7 @@ func (provider *Docker) loadDockerConfig(containersInspected []dockerData) *type
"hasMaxConnLabels": provider.hasMaxConnLabels,
"getMaxConnAmount": provider.getMaxConnAmount,
"getMaxConnExtractorFunc": provider.getMaxConnExtractorFunc,
"getSticky": provider.getSticky,
"replace": replace,
}
@ -260,19 +261,26 @@ func (provider *Docker) loadDockerConfig(containersInspected []dockerData) *type
return provider.containerFilter(container)
}, containersInspected).([]dockerData)
// sticky backends
stickycontainers := map[string][]dockerData{}
frontends := map[string][]dockerData{}
for _, container := range filteredContainers {
frontendName := provider.getFrontendName(container)
frontends[frontendName] = append(frontends[frontendName], container)
frontends[frontendName] = append(frontends[frontendName], container)
stickycontainers[provider.getBackend(container)] = container
}
templateObjects := struct {
Containers []dockerData
Frontends map[string][]dockerData
Domain string
Containers []dockerData
Frontends map[string][]dockerData
StickyContainers map[string][]dockerData
Domain string
}{
filteredContainers,
frontends,
stickycontainers,
provider.Domain,
}
@ -441,9 +449,9 @@ func (provider *Docker) getWeight(container dockerData) string {
func (provider *Docker) getSticky(container dockertypes.ContainerJSON) string {
if label, err := getLabel(container, "traefik.stickysession"); err == nil {
return true
return "true"
}
return false
return "false"
}
func (provider *Docker) getDomain(container dockerData) string {

View file

@ -940,7 +940,7 @@ func TestDockerLoadDockerConfig(t *testing.T) {
},
},
CircuitBreaker: nil,
LoadBalancer: nil,
LoadBalancer: &types.LoadBalancer{Sticky: false, Method: ""},
},
},
},
@ -1027,7 +1027,7 @@ func TestDockerLoadDockerConfig(t *testing.T) {
},
},
CircuitBreaker: nil,
LoadBalancer: nil,
LoadBalancer: &types.LoadBalancer{Sticky: false, Method: ""},
},
},
},

View file

@ -16,10 +16,6 @@
extractorfunc = "{{getMaxConnExtractorFunc . }}"
{{end}}
[backends.backend-{{getBackend .}}.servers.server-{{.Name | replace "/" "" | replace "." "-"}}]
url = "{{getProtocol .}}://{{getIPAddress .}}:{{getPort .}}"
weight = {{getWeight .}}
{{end}}
[frontends]{{range $frontend, $containers := .Frontends}}
[frontends."frontend-{{$frontend}}"]{{$container := index $containers 0}}