8000 Add support for filtering on node labels by anshulpundir · Pull Request #37650 · moby/moby · GitHub
[go: up one dir, main page]

Skip to content

Conversation

anshulpundir
Copy link
Contributor
@anshulpundir anshulpundir commented Aug 15, 2018 8000

Copy link
Member
@yongtang yongtang left a 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 💚

Copy link
Member
@thaJeztah thaJeztah left a 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 filter
    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
8000
Copy link
codecov bot commented Aug 16, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@2629fe9). Click here to learn what that means.
The diff coverage is 0%.

@@            Coverage Diff            @@
##             master   #37650   +/-   ##
=========================================
  Coverage          ?   36.13%           
=========================================
  Files             ?      610           
  Lines             ?    45056           
  Branches          ?        0           
=========================================
  Hits              ?    16282           
  Misses            ?    26531           
  Partials          ?     2243

@anshulpundir
Copy link
Contributor Author

addressed comments from @thaJeztah

Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

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

typo s/ilter/filter/

Copy link
Member

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
Copy link
Member

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?

@andrewhsu
Copy link
Contributor

I'd suggest ignoring the z errors because we've had intermittent networking issues with our z infrastructure.

Downloading 'library/busybox:glibc@sha256:0b55a30394294ab23b9afd58fab94e61a923f5834fba7ddbae7f8e0c11ba85e6' (1 layers)...
curl: (28) Operation timed out after 300521 milliseconds with 0 out of 0 bytes received

api/swagger.yaml Outdated
Copy link
Member

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 ^^

Copy link
Member

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 👼

Copy link
Member

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

Copy link
Member

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)

Copy link
Member

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>

Copy link
Member
@thaJeztah thaJeztah 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!

Copy link
Contributor
@andrewhsu andrewhsu left a 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

@thaJeztah
Copy link
Member

Failure on experimental (think that's a flaky)

19:17:48 FAIL: docker_api_swarm_test.go:296: DockerSwarmSuite.TestAPISwarmLeaderElection
19:17:48 
19:17:48 [dfbd0fadafb65] waiting for daemon to start
19:17:48 [dfbd0fadafb65] daemon started
19:17:48 
19:17:48 [d96abff1621cb] waiting for daemon to start
19:17:48 [d96abff1621cb] daemon started
19:17:48 
19:17:48 [df10c3972bb8f] waiting for daemon to start
19:17:48 [df10c3972bb8f] daemon started
19:17:48 
19:17:48 [dfbd0fadafb65] exiting daemon
19:17:48 assertion failed: error is not nil: Error response from daemon: rpc error: code = DeadlineExceeded desc = context deadline exceeded
19:17:48 [d96abff1621cb] exiting daemon
19:17:48 [df10c3972bb8f] exiting daemon

@thaJeztah thaJeztah changed the title Bump SwarmKit to 496d19be63751d60a55887604683e5cb1a5541aa Add support for filtering on node labels Aug 21, 2018
…ring on node labels.

Signed-off-by: Anshul Pundir <anshul.pundir@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
Copy link
Member

Dropped the swarmkit bump commit, because master is now ahead of that commit, and fixed the merge-conflict in docs/api/version-history.md

@thaJeztah
Copy link
Member

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)

@anshulpundir
Copy link
Contributor Author
anshulpundir commented Aug 21, 2018

thx adjusting this PR! @thaJeztah

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.

6 participants
0