From cbbb5f4ccb41824093fe75f520425b207afd362c Mon Sep 17 00:00:00 2001 From: Diego de Oliveira Date: Tue, 31 Jan 2017 12:48:21 -0200 Subject: [PATCH] Fix marathon provider The IP-Per-Task PR introduced a bug using the marathon application port mapping. This port should be used only in the proxy server, the downstream connection should be always made with the task port. This commit fix the regression and adds a unit test to prevent new problems in this setup. --- provider/marathon.go | 5 ----- provider/marathon_test.go | 13 +++++++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/provider/marathon.go b/provider/marathon.go index 3cd50a1f1..fa78ff03a 100644 --- a/provider/marathon.go +++ b/provider/marathon.go @@ -496,11 +496,6 @@ func (provider *Marathon) getCircuitBreakerExpression(application marathon.Appli func processPorts(application marathon.Application, task marathon.Task) []int { - // First using application ports - if len(application.Ports) > 0 { - return application.Ports - } - // Using default port configuration if task.Ports != nil && len(task.Ports) > 0 { return task.Ports diff --git a/provider/marathon_test.go b/provider/marathon_test.go index 3166ae19e..c4a5b5f98 100644 --- a/provider/marathon_test.go +++ b/provider/marathon_test.go @@ -1077,6 +1077,19 @@ func TestMarathonGetPort(t *testing.T) { Ports: []int{80, 443}, }, expected: "443", + }, { + applications: []marathon.Application{ + { + ID: "application-with-port", + Ports: []int{9999}, + Labels: &map[string]string{}, + }, + }, + task: marathon.Task{ + AppID: "application-with-port", + Ports: []int{7777}, + }, + expected: "7777", }, }