Skip to content

Commit

Permalink
[marathon] Assign filtered tasks to apps contained in slice.
Browse files Browse the repository at this point in the history
We previously assigned them to a copy of each application, which
effectively disabled all filtering.

Fixes a bug introduced along commit 779eeba.
  • Loading branch information
timoreimann committed Jul 20, 2017
1 parent 074b31b commit 75d1e4d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions provider/marathon/marathon.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ func (p *Provider) loadMarathonConfig() *types.Configuration {
}

filteredApps := fun.Filter(p.applicationFilter, applications.Apps).([]marathon.Application)
for _, app := range filteredApps {
app.Tasks = fun.Filter(func(task *marathon.Task) bool {
for i, app := range filteredApps {
filteredApps[i].Tasks = fun.Filter(func(task *marathon.Task) bool {
return p.taskFilter(*task, app)
}, app.Tasks).([]*marathon.Task)
}
Expand Down
28 changes: 28 additions & 0 deletions provider/marathon/marathon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,31 @@ func TestMarathonLoadConfigNonAPIErrors(t *testing.T) {
},
},
},
{
desc: "filtered task",
application: marathon.Application{
Ports: []int{80},
Labels: &map[string]string{},
},
task: marathon.Task{
Ports: []int{80},
State: "TASK_STAGING",
},
expectedFrontends: map[string]*types.Frontend{
"frontend-app": {
Backend: "backend-app",
PassHostHeader: true,
BasicAuth: []string{},
EntryPoints: []string{},
Routes: map[string]types.Route{
"route-host-app": {
Rule: "Host:app.docker.localhost",
},
},
},
},
expectedBackends: nil,
},
{
desc: "load balancer / circuit breaker labels",
application: marathon.Application{
Expand Down Expand Up @@ -328,6 +353,9 @@ func TestMarathonLoadConfigNonAPIErrors(t *testing.T) {
t.Parallel()
c.application.ID = "/app"
c.task.ID = "task"
if c.task.State == "" {
c.task.State = "TASK_RUNNING"
}
c.application.Tasks = []*marathon.Task{&c.task}
fakeClient := newFakeClient(false,
marathon.Applications{Apps: []marathon.Application{c.application}})
Expand Down

0 comments on commit 75d1e4d

Please sign in to comment.