Merge pull request #195 from emilevauge/fix-regression-marathon-backends
Fix regression on marathon backend
This commit is contained in:
commit
e9c23195a0
4 changed files with 25 additions and 14 deletions
|
@ -90,6 +90,7 @@ func (provider *Marathon) loadMarathonConfig() *types.Configuration {
|
||||||
"getEntryPoints": provider.getEntryPoints,
|
"getEntryPoints": provider.getEntryPoints,
|
||||||
"getFrontendValue": provider.getFrontendValue,
|
"getFrontendValue": provider.getFrontendValue,
|
||||||
"getFrontendRule": provider.getFrontendRule,
|
"getFrontendRule": provider.getFrontendRule,
|
||||||
|
"getFrontendBackend": provider.getFrontendBackend,
|
||||||
"replace": replace,
|
"replace": replace,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +314,16 @@ func (provider *Marathon) getFrontendRule(application marathon.Application) stri
|
||||||
return "Host"
|
return "Host"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *Marathon) getBackend(application marathon.Application) string {
|
func (provider *Marathon) getBackend(task marathon.Task, applications []marathon.Application) string {
|
||||||
|
application, errApp := getApplication(task, applications)
|
||||||
|
if errApp != nil {
|
||||||
|
log.Errorf("Unable to get marathon application from task %s", task.AppID)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return provider.getFrontendBackend(application)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (provider *Marathon) getFrontendBackend(application marathon.Application) string {
|
||||||
if label, err := provider.getLabel(application, "traefik.backend"); err == nil {
|
if label, err := provider.getLabel(application, "traefik.backend"); err == nil {
|
||||||
return label
|
return label
|
||||||
}
|
}
|
||||||
|
|
|
@ -851,7 +851,7 @@ func TestMarathonGetBackend(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, a := range applications {
|
for _, a := range applications {
|
||||||
actual := provider.getBackend(a.application)
|
actual := provider.getFrontendBackend(a.application)
|
||||||
if actual != a.expected {
|
if actual != a.expected {
|
||||||
t.Fatalf("expected %q, got %q", a.expected, actual)
|
t.Fatalf("expected %q, got %q", a.expected, actual)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
{{$apps := .Applications}}
|
{{$apps := .Applications}}
|
||||||
[backends]{{range .Tasks}}
|
[backends]{{range .Tasks}}
|
||||||
[backends.backend{{with index $apps 0 }}{{getBackend .}}{{end}}.servers.server-{{.ID | replace "." "-"}}]
|
[backends.backend{{getBackend . $apps}}.servers.server-{{.ID | replace "." "-"}}]
|
||||||
url = "{{getProtocol . $apps}}://{{.Host}}:{{getPort . $apps}}"
|
url = "{{getProtocol . $apps}}://{{.Host}}:{{getPort . $apps}}"
|
||||||
weight = {{getWeight . $apps}}
|
weight = {{getWeight . $apps}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
[frontends]{{range .Applications}}
|
[frontends]{{range .Applications}}
|
||||||
[frontends.frontend{{.ID | replace "/" "-"}}]
|
[frontends.frontend{{.ID | replace "/" "-"}}]
|
||||||
backend = "backend{{getBackend .}}"
|
backend = "backend{{getFrontendBackend .}}"
|
||||||
passHostHeader = {{getPassHostHeader .}}
|
passHostHeader = {{getPassHostHeader .}}
|
||||||
entryPoints = [{{range getEntryPoints .}}
|
entryPoints = [{{range getEntryPoints .}}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
|
|
|
@ -31,6 +31,7 @@ slave:
|
||||||
- /usr/bin/docker:/usr/bin/docker:ro
|
- /usr/bin/docker:/usr/bin/docker:ro
|
||||||
- /usr/lib/x86_64-linux-gnu/libapparmor.so.1:/usr/lib/x86_64-linux-gnu/libapparmor.so.1:ro
|
- /usr/lib/x86_64-linux-gnu/libapparmor.so.1:/usr/lib/x86_64-linux-gnu/libapparmor.so.1:ro
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
- /lib/x86_64-linux-gnu/libsystemd-journal.so.0:/lib/x86_64-linux-gnu/libsystemd-journal.so.0
|
||||||
|
|
||||||
marathon:
|
marathon:
|
||||||
image: mesosphere/marathon:v0.13.0
|
image: mesosphere/marathon:v0.13.0
|
||||||
|
|
Loading…
Reference in a new issue