Skip to content

Commit

Permalink
Merge pull request #17 from DBCDK/skipNonHelthyTasks
Browse files Browse the repository at this point in the history
Hack To skip Task where HealthCheckResults[0].Alive is False
  • Loading branch information
srhb authored Feb 1, 2018
2 parents c8a673f + 859e49c commit 42a2e9f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions marathon/marathon.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func UpdateBackends(config *util.Config) (map[string][]util.Backend, error) {
}

var indexedApps = indexApps(apps)
var indexedTasks = indexTasks(tasks)
var indexedTasks = indexHealthyTasks(tasks)
var labelPrefix = config.Marathon.LabelPrefix + ".port."

for appId, app := range indexedApps {
Expand Down Expand Up @@ -187,14 +187,17 @@ func indexApps(apps Apps) (indexedApps map[string]App) {
return indexedApps
}

func indexTasks(tasks Tasks) (indexedTasks map[string][]Task) {
func indexHealthyTasks(tasks Tasks) (indexedTasks map[string][]Task) {
indexedTasks = make(map[string][]Task)

for _, task := range tasks.Tasks {
if indexedTasks[task.Id] == nil {
indexedTasks[task.Id] = []Task{}
}
indexedTasks[task.AppId] = append(indexedTasks[task.AppId], task)
// Skip non healthy Tasks
if len(task.HealthCheckResults) > 0 && task.HealthCheckResults[0].Alive {
indexedTasks[task.AppId] = append(indexedTasks[task.AppId], task)
}
}
return indexedTasks
}

0 comments on commit 42a2e9f

Please sign in to comment.