-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Marathon constraints filtering #2388
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
Conversation
e2cfb14 to
2e29778
Compare
2e29778 to
2e632a0
Compare
|
@timoreimann WDYT ? |
timoreimann
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feature definitely makes sense to me since Marathon constraints are a very canonical way to filter with this provider.
I left a few comments.
provider/marathon/marathon.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a boolean flag, can we have a verb-ish prefix? How about something like filterMarathonConstraints?
provider/marathon/marathon.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we can drop the right-hand expression and merge the left-hand one with the previous line like this:
if p.MarathonConstraints && app.Constraints != nil {
for _, list := range *app.Constraints {
provider/marathon/marathon_test.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we group by Nevermind actually, it doesn't make sense here.expected outcome, going with false first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should elaborate just a bit what "enable" means (i.e., that we parse Marathon constraints and treat the compound constraint parts as a single tag to match literally).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we phrase this as Enable filtering by Marathon constraints.?
provider/marathon/builder_test.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the function signature, it might not be immediately clear to the caller that colons must be used as separators. I know it's only a few lines below, but how about making the function variadic at the second parameter (i.e., constraint(value1 string, values... string) func(*marathon.Application)) to increase clarity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was really trying to keep it as a single string, as in the Marathon config (not using the json API), it is defined as a single string with 3 components, separated with a :. Even the Marathon UI uses just a single text field to add the constrain labels, so I'd rather keep this aligned, to be consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a reasonable argument. Let's keep a single string then.
provider/marathon/marathon.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename list to constraintParts? That's also how the official documentation calls them.
provider/marathon/marathon_test.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we omit marathonConstraint (and possibly other parameters) when they are not needed / relevant for a test?
timoreimann
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small bits left.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we phrase this as Enable filtering by Marathon constraints.?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: constraints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: verbatim
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to update the name
provider/marathon/marathon.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can omit the last expression on the constraint length.
provider/marathon/marathon_test.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's prepend this by filter too to match the real flag name.
04539de to
4946c6f
Compare
timoreimann
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM -- thanks, Alex. 👏
juliens
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
ldez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
4946c6f to
bc4a411
Compare
What does this PR do?
Add support for filtering based on Marathon-defined constraints, as described in https://mesosphere.github.io/marathon/docs/constraints.html
Motivation
Many Marathon clusters have applications deployed with various "constraints", configuring things like application service affinity, cluster binding, etc. It would be very helpful to not have to add additional/duplicate
traefik.tagslabels to the applications and to be able to filter using already defined Marathon constraints instead.More