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

make node ls filtering support both node label and engine label #2062

Conversation

allencloud
Copy link
Contributor

This pr tries to fix moby/moby#27231 and moby/moby#28209

Currently in swarmkit ListNode only supports engine label filtering, while not node label filtering. But this PR makes both supported.

Signed-off-by: allencloud allen.sun@daocloud.io

@allencloud allencloud force-pushed the label-filtering-node-by-both-engine-and-node-labels branch from b46ba7a to 37c40ee Compare March 28, 2017 05:12
@codecov
Copy link

codecov bot commented Mar 28, 2017

Codecov Report

Merging #2062 into master will decrease coverage by 3.72%.
The diff coverage is 100%.

@@            Coverage Diff            @@
##           master   #2062      +/-   ##
=========================================
- Coverage   59.62%   55.9%   -3.73%     
=========================================
  Files         118      55      -63     
  Lines       19544    8771   -10773     
=========================================
- Hits        11654    4903    -6751     
+ Misses       6541    3342    -3199     
+ Partials     1349     526     -823

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update be68371...0b97e37. Read the comment docs.

@allencloud allencloud force-pushed the label-filtering-node-by-both-engine-and-node-labels branch from 37c40ee to 22e1b87 Compare March 28, 2017 05:57
@@ -136,6 +136,10 @@ func (s *Server) ListNodes(ctx context.Context, request *api.ListNodesRequest) (
if len(request.Filters.Labels) == 0 {
return true
}
if filterMatchLabels(e.Spec.Annotations.Labels, request.Filters.Labels) == true {
Copy link
Member

Choose a reason for hiding this comment

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

I think that for the SwarmKit side, this should be a separate filter, or at least a way to distinguish between "node" labels and "engine" labels.

We can still decide to keep the "docker" UX the same (filtering by labels using both "engine" and "node" labels), but at least it gives control over what is filtered on at the API level.

@aluzzardi @allencloud wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the separated thing is reasonable. Updated that.

@allencloud allencloud force-pushed the label-filtering-node-by-both-engine-and-node-labels branch from 22e1b87 to 4384ff7 Compare March 29, 2017 10:00
@aaronlehmann
Copy link
Collaborator

I think what @thaJeztah had in mind was two separate fields in the API to filter on node labels vs. engine labels.

@allencloud allencloud force-pushed the label-filtering-node-by-both-engine-and-node-labels branch from 4384ff7 to 99c64e5 Compare April 4, 2017 02:50
@thaJeztah
Copy link
Member

Yes; didn't look at the last changes in depth, but they should be "separate" options/filters in SwarmKit

@allencloud allencloud force-pushed the label-filtering-node-by-both-engine-and-node-labels branch 5 times, most recently from 47139d7 to b8c67ec Compare April 13, 2017 02:31
Signed-off-by: allencloud <allen.sun@daocloud.io>
@allencloud allencloud force-pushed the label-filtering-node-by-both-engine-and-node-labels branch from b8c67ec to 0b97e37 Compare April 13, 2017 05:49
repeated NodeRole roles = 5;
map<string, string> node_labels = 3;
map<string, string> engine_labels = 4;
repeated NodeSpec.Membership memberships = 5;
Copy link
Collaborator

Choose a reason for hiding this comment

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

It isn't okay to renumber existing values.

@nishanttotla
Copy link
Contributor

@allencloud are you still working on this PR? We might want to push this relatively soon, so if you're unable to get to it, I'd be happy to carry it for you.

@allencloud
Copy link
Contributor Author

Hi, @nishanttotla
Thanks for your suggestion. Actually currently I am busy with doing something else here. So it is pity for me to carry this on.
So, it could not be better if you could help us to solve this. Thanks a lot.

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

Successfully merging this pull request may close these issues.

Filtering nodes doesn't return a result
5 participants