Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow traefik.port to not be in the list of marathon ports #1309

Closed
wants to merge 0 commits into from
Closed

Allow traefik.port to not be in the list of marathon ports #1309

wants to merge 0 commits into from

Conversation

nicgrayson
Copy link

Fixes #261

This is needed when using --host and the port cannot be provided to the marathon app.

Copy link
Contributor

@timoreimann timoreimann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I noticed the observed behavior too, agree it's a bit too restrictive.

I left two comments.

@@ -551,7 +551,7 @@ func TestMarathonTaskFilter(t *testing.T) {
},
},
},
expected: false,
expected: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of flipping the expected flag, I think we should remove the entire test case as we have removed the restriction to specify a known port only.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the specify-port-number test case (lines 520 ff.) will cover the updated functionality. Could you please update it in the following regards:

  1. Change the label port from 80 to 8080 (line 530).
  2. Remove the unneeded application ports (complete line 522).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes a ton of sense i'll rebase into one commit shortly

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this change. I wasn't sure how these tests work but this passes now. Does it read the application section then expect the task section?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at end of the test case definitions, you can see what it does: For each test case, it directly calls the filter function passing our test fixtures (i.e., the application and task structs we set up) and expects the filtering to apply (or not apply) depending on the expected outcome.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that. I redid the commit. Now not removing that test case.

@@ -519,57 +519,19 @@ func TestMarathonTaskFilter(t *testing.T) {
{
task: marathon.Task{
AppID: "specify-port-number",
Ports: []int{80, 443},
Ports: []int{8080},
},
applications: &marathon.Applications{
Apps: []marathon.Application{
{
ID: "specify-port-number",
Ports: []int{80, 443},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the application ports. They are not needed for the test.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

applications: &marathon.Applications{
Apps: []marathon.Application{
{
ID: "specify-port-index",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you removed a bit too much: The index functionality is still there, hence this test case should stay.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed this up. The ports are required so it doesn't get filtered from this section of that function: https://github.com/containous/traefik/blob/master/provider/marathon.go#L199

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The processPorts() function returns a non-empty list of ports if there are task ports. Since we define task ports during our test fixture, we should be able to make the test pass even without the application ports, shouldn't we?

In fact, I don't see application ports being used anywhere in the production code, so I'm suspecting they are a relict that could be removed from all tests. For now though, I'd prefer them to be removed from the tests we touch and leave a possibly wider cleanup to a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also guess you meant to send your reply to my other comment. This comment is about the specify-port-index being removed. Could you still address it please?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Contributor

@timoreimann timoreimann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- thanks a lot!

Copy link
Member

@emilevauge emilevauge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Thanks @nicgrayson :)

@emilevauge emilevauge closed this Apr 6, 2017
@emilevauge
Copy link
Member

emilevauge commented Apr 6, 2017

@nicgrayson ouch, I think broke everything, your commits have disappeared 😨 Could you push -force from your local repo?
I created a new PR with your commit #1394 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Marathon label traefik.port cannot be parsed
4 participants