-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Add support for filtering on node labels #37650
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
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 once janky is 💚
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.
Thanks! Looks like we need some changes to make the new filter work;
- update
newListNodesFilters()
to accept the new filtermoby/daemon/cluster/filters.go
Lines 12 to 46 in 3a633a7
func newListNodesFilters(filter filters.Args) (*swarmapi.ListNodesRequest_Filters, error) { accepted := map[string]bool{ "name": true, "id": true, "label": true, "role": true, "membership": true, } if err := filter.Validate(accepted); err != nil { return nil, err } f := &swarmapi.ListNodesRequest_Filters{ NamePrefixes: filter.Get("name"), IDPrefixes: filter.Get("id"), Labels: runconfigopts.ConvertKVStringsToMap(filter.Get("label")), } for _, r := range filter.Get("role") { if role, ok := swarmapi.NodeRole_value[strings.ToUpper(r)]; ok { f.Roles = append(f.Roles, swarmapi.NodeRole(role)) } else if r != "" { return nil, fmt.Errorf("Invalid role filter: '%s'", r) } } for _, a := range filter.Get("membership") { if membership, ok := swarmapi.NodeSpec_Membership_value[strings.ToUpper(a)]; ok { f.Memberships = append(f.Memberships, swarmapi.NodeSpec_Membership(membership)) } else if a != "" { return nil, fmt.Errorf("Invalid membership filter: '%s'", a) } } return f, nil } - update the Swagger file to document the newly accepted filter; https://github.com/moby/moby/blob/bd06a5ea4df919ff323510fba10801b5673a3af6/api/swagger.yaml?utf8=✓#L8577-L8589
- add a note to the API changelog to mention the new filter; https://github.com/moby/moby/blob/master/docs/api/version-history.md. This change will be in API 1.39, so either a new entry should be added for that version, or that would come with #37472 (once merged)
Codecov Report
@@ Coverage Diff @@
## master #37650 +/- ##
=========================================
Coverage ? 36.13%
=========================================
Files ? 610
Lines ? 45056
Branches ? 0
=========================================
Hits ? 16282
Misses ? 26531
Partials ? 2243 |
addressed comments from @thaJeztah |
daemon/cluster/filters.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding th 8000 is comment
The reason will be displayed to describe this comment to others. Learn more.
looks like this should be singular
docs/api/version-history.md
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.
typo s/ilter/filter/
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.
also s/label/node-label/
api/swagger.yaml
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.
also thinking if this should be node.label
(full stop, instead of hyphen), as was proposed in #28209
ping @vdemeester @dperny?
I'd suggest ignoring the z errors because we've had intermittent networking issues with our z infrastructure.
|
api/swagger.yaml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to des 8000 cribe this comment to others. Learn more.
hm, looks like you changed the example value, instead of the "key"; we could discuss quickly, but I think the idea in #28209 was to have --filter node.label=foobar
(so node.label
instead of node-label
)
@vdemeester ^^
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.
Yeah, to have node.label
, engine.label
and label
. The dot .
was maintly to be consistent with constraint if I rembember correctly 👼
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.
Ah; yes; that was the reason
daemon/cluster/filters.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.
same here (and other places below)
docs/api/version-history.md
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.
The examples here still don't match; e.g. label=<key>=<value>
should be either node-label=<key>=<value>
or node.label=<key>=<value>
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!
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
ignore the z error:
curl: (56) SSL read: error:00000000:lib(0):func(0):reason(0), errno 104
because z infrastructure issues
Failure on experimental (think that's a flaky)
|
…ring on node labels. Signed-off-by: Anshul Pundir <anshul.pundir@docker.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Dropped the swarmkit bump commit, because master is now ahead of that commit, and fixed the merge-conflict in docs/api/version-history.md |
Argh. Janky failing again on that swagger-check; #36714. I'll restart, but we can likely look at the "experimental" build as well (which should run the same tests) |
thx adjusting this PR! @thaJeztah |
Full diff: moby/swarmkit@8852e88...496d19b
Relevant changes:
ping @andrewhsu @thaJeztah @dperny