Allow traefik.port to not be in the list of marathon ports
This commit is contained in:
parent
e1aa16ae70
commit
4eb779e596
2 changed files with 4 additions and 37 deletions
|
@ -235,24 +235,11 @@ func (provider *Marathon) taskFilter(task marathon.Task, applications *marathon.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if portValueLabel != "" {
|
if portValueLabel != "" {
|
||||||
port, err := strconv.Atoi((*application.Labels)["traefik.port"])
|
_, err := strconv.Atoi((*application.Labels)["traefik.port"])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debugf("Filtering marathon task %s with unexpected value for traefik.port label", task.AppID)
|
log.Debugf("Filtering marathon task %s with unexpected value for traefik.port label", task.AppID)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
var foundPort bool
|
|
||||||
for _, exposedPort := range ports {
|
|
||||||
if port == exposedPort {
|
|
||||||
foundPort = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !foundPort {
|
|
||||||
log.Debugf("Filtering marathon task %s without a matching port for traefik.port label", task.AppID)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//filter healthchecks
|
//filter healthchecks
|
||||||
|
|
|
@ -519,39 +519,19 @@ func TestMarathonTaskFilter(t *testing.T) {
|
||||||
{
|
{
|
||||||
task: marathon.Task{
|
task: marathon.Task{
|
||||||
AppID: "specify-port-number",
|
AppID: "specify-port-number",
|
||||||
Ports: []int{80, 443},
|
Ports: []int{80},
|
||||||
},
|
},
|
||||||
applications: &marathon.Applications{
|
applications: &marathon.Applications{
|
||||||
Apps: []marathon.Application{
|
Apps: []marathon.Application{
|
||||||
{
|
{
|
||||||
ID: "specify-port-number",
|
ID: "specify-port-number",
|
||||||
Ports: []int{80, 443},
|
|
||||||
Labels: &map[string]string{
|
|
||||||
"traefik.port": "80",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
expected: true,
|
|
||||||
exposedByDefault: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
task: marathon.Task{
|
|
||||||
AppID: "specify-unknown-port-number",
|
|
||||||
Ports: []int{80, 443},
|
|
||||||
},
|
|
||||||
applications: &marathon.Applications{
|
|
||||||
Apps: []marathon.Application{
|
|
||||||
{
|
|
||||||
ID: "specify-unknown-port-number",
|
|
||||||
Ports: []int{80, 443},
|
|
||||||
Labels: &map[string]string{
|
Labels: &map[string]string{
|
||||||
"traefik.port": "8080",
|
"traefik.port": "8080",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: false,
|
expected: true,
|
||||||
exposedByDefault: true,
|
exposedByDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue