mirror of
https://github.com/traefik/traefik.git
synced 2025-05-29 02:51:26 +00:00
Merge pull request #83 from emilevauge/marathon-filter-healthchecks
Add healthcheck filter in marathon tasks
This commit is contained in:
commit
aae7941689
21
marathon.go
21
marathon.go
@ -114,7 +114,7 @@ func (provider *MarathonProvider) loadMarathonConfig() *Configuration {
|
|||||||
//filter tasks
|
//filter tasks
|
||||||
filteredTasks := fun.Filter(func(task marathon.Task) bool {
|
filteredTasks := fun.Filter(func(task marathon.Task) bool {
|
||||||
if len(task.Ports) == 0 {
|
if len(task.Ports) == 0 {
|
||||||
log.Debug("Filtering marathon task without port", task.AppID)
|
log.Debug("Filtering marathon task without port %s", task.AppID)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
application, errApp := getApplication(task, applications.Apps)
|
application, errApp := getApplication(task, applications.Apps)
|
||||||
@ -124,13 +124,28 @@ func (provider *MarathonProvider) loadMarathonConfig() *Configuration {
|
|||||||
}
|
}
|
||||||
_, err := strconv.Atoi(application.Labels["traefik.port"])
|
_, err := strconv.Atoi(application.Labels["traefik.port"])
|
||||||
if len(application.Ports) > 1 && err != nil {
|
if len(application.Ports) > 1 && err != nil {
|
||||||
log.Debug("Filtering marathon task with more than 1 port and no traefik.port label", task.AppID)
|
log.Debugf("Filtering marathon task %s with more than 1 port and no traefik.port label", task.AppID)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if application.Labels["traefik.enable"] == "false" {
|
if application.Labels["traefik.enable"] == "false" {
|
||||||
log.Debug("Filtering disabled marathon task", task.AppID)
|
log.Debugf("Filtering disabled marathon task %s", task.AppID)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
//filter healthchecks
|
||||||
|
if application.HasHealthChecks() {
|
||||||
|
if task.HasHealthCheckResults() {
|
||||||
|
for _, healthcheck := range task.HealthCheckResult {
|
||||||
|
// found one bad healthcheck, return false
|
||||||
|
if !healthcheck.Alive {
|
||||||
|
log.Debugf("Filtering marathon task %s with bad healthcheck", task.AppID)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.Debugf("Filtering marathon task %s with bad healthcheck", task.AppID)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}, tasks.Tasks).([]marathon.Task)
|
}, tasks.Tasks).([]marathon.Task)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user