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

Add support for several ECS backends #1913

Merged
merged 7 commits into from Aug 22, 2017

Conversation

mmatur
Copy link
Member

@mmatur mmatur commented Aug 3, 2017

Description

The goal of this PR is to add support for several ECS backends.
Two new fields has been added for ECS provider:

  • Clusters: used to define explicit list of clusters

  • AutoDiscoverClusters: used to enable auto discover clusters functionality. If this property is set to true, Clusters property will be ignored. Træfik ECS policy need to be updated with "ecs:ListClusters", "ecs:DescribeClusters"

Fixes #1570

To avoid breaking change ECS provider accept old field Cluster. If AutoDiscoverClusters is set Cluster field will be ignored.

Copy link
Member

@ldez ldez left a comment

Choose a reason for hiding this comment

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

Great job!

Could you add some integration tests?


//Set adds strings elem into the the parser
//it splits str on , and ;
func (ns *Clusters) Set(str string) error {
Copy link
Member

Choose a reason for hiding this comment

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

Could you add unit tests?

// Clusters holds ecs clusters name
type Clusters []string

//Set adds strings elem into the the parser
Copy link
Member

Choose a reason for hiding this comment

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

could you add space between // and the comment. Same for others.

@ldez ldez changed the title [ecs] Add support for several ECS backends Add support for several ECS backends Aug 3, 2017
@mmatur
Copy link
Member Author

mmatur commented Aug 3, 2017

@ldez ECS provider use AWS API. Do you want that I mock AWS API to be able to do some integration tests ?

@ldez
Copy link
Member

ldez commented Aug 4, 2017

Maybe you can use https://github.com/localstack/localstack?

@mmatur
Copy link
Member Author

mmatur commented Aug 4, 2017

I have already watch localstack. but currently they not provide ecs and ec2 endpoints. I will try to work on this new feature on localstack when i will have time

Copy link
Member

@ldez ldez left a comment

Choose a reason for hiding this comment

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

LGTM

@ldez ldez added this to the 1.4 milestone Aug 10, 2017
@ldez ldez added the size/M label Aug 16, 2017
Copy link
Contributor

@nmengin nmengin left a comment

Choose a reason for hiding this comment

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

@mmatur Many thanks for this amaz(on)ing PR 😝

I just have one suggestion to do.

input.NextToken = result.NextToken
result, _ = client.ecs.ListClusters(input)
}
clustersArn = append(clustersArn, result.ClusterArns...)
Copy link
Contributor

@nmengin nmengin Aug 17, 2017

Choose a reason for hiding this comment

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

In the way to avoid repetition and possible problem if result == nil, what is your mind about the suggestion described below?

for {
    if result, _ := client.ecs.ListClusters(input); result != nil {
        clustersArn = append(clustersArn, result.ClusterArns...) 		  		 
	input.NextToken = result.NextToken
        if result.NextToken == nil {
            break
        }
    } else {
        break
    }
}

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that result can never be nil. But I like the suggestion, this is simplifying the code.
I will do the change

Copy link
Contributor

@nmengin nmengin left a comment

Choose a reason for hiding this comment

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

LGTM 👏

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.

Thanks a lot @mmatur, great job 👏
Few comments though :)

clusters = append(clusters, *carns)
}
} else if p.Cluster != "" {
clusters = Clusters{p.Cluster}
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a log.warn to inform the user that he uses a deprecated option? And also add a // TODO to remind us to remove this in the future?

if p.AutoDiscoverClusters {
input := &ecs.ListClustersInput{}
for {
if result, _ := client.ecs.ListClusters(input); result != nil {
Copy link
Member

Choose a reason for hiding this comment

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

You should not discard the returned error here

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.

Thanks @mmatur :)
LGTM

@traefiker traefiker merged commit 8765494 into traefik:master Aug 22, 2017
@mmatur mmatur deleted the ecs-multiple-backends branch August 22, 2017 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants