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

Filtering nodes doesn't return a result #27231

Open
sebgie opened this issue Oct 8, 2016 · 14 comments · Fixed by docker/cli#2951
Open

Filtering nodes doesn't return a result #27231

sebgie opened this issue Oct 8, 2016 · 14 comments · Fixed by docker/cli#2951
Labels
area/swarm exp/intermediate kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. version/1.12

Comments

@sebgie
Copy link

sebgie commented Oct 8, 2016

Description

Hi, I have started to use 1.12 with it's new features lately. I have a 4 node cluster (1 manager, 3 workers with swarm mode) and try to put workloads on dedicated machines. While doing that I came accross either a bug or something that is missing from documentation?

I have added a label to one of my nodes and then try to execute docker node ls with a filter as described here: https://docs.docker.com/engine/reference/commandline/node_ls/#filtering. Unfortunately I don't get the expected response?

Steps to reproduce the issue:

# docker node update --label-add test dev-swarm-04
dev-swarm-04

# docker node inspect dev-swarm-04
[
    {
        "ID": "7p470z31yf2u27t7wx48og9b0",
        "Version": {
            "Index": 8545
        },
        "CreatedAt": "2016-10-05T13:42:10.303870096Z",
        "UpdatedAt": "2016-10-08T12:15:32.624496559Z",
        "Spec": {
            "Labels": {
                "test": ""
            },
            "Role": "worker",
            "Availability": "active"
        },
        "Description": {
            "Hostname": "dev-swarm-04",
            "Platform": {
                "Architecture": "x86_64",
                "OS": "linux"
            },
            "Resources": {
                "NanoCPUs": 4000000000,
                "MemoryBytes": 8371408896
            },
            "Engine": {
                "EngineVersion": "1.12.1",
                "Plugins": [
                    {
                        "Type": "Network",
                        "Name": "bridge"
                    },
                    {
                        "Type": "Network",
                        "Name": "host"
                    },
                    {
                        "Type": "Network",
                        "Name": "null"
                    },
                    {
                        "Type": "Network",
                        "Name": "overlay"
                    },
                    {
                        "Type": "Volume",
                        "Name": "local"
                    }
                ]
            }
        },
        "Status": {
            "State": "ready"
        }
    }
]

# docker node ls -f label=test
ID  HOSTNAME  STATUS  AVAILABILITY  MANAGER STATUS

Describe the results you received:
No nodes found.

Describe the results you expected:
One node (dev-swarm-04) found.

Additional information you deem important (e.g. issue happens only occasionally):
Additonally I couldn't find any documentation how I would use a value with my label.

# docker node ls -f label=test=value?
# docker node ls -f label=test:value?
# docker node ls -f label.test=value?

Using the label as a constraint to create a service works flawlessly 👍.
Thanks for your help :).

Output of docker version:

Client:
 Version:      1.12.1
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   23cf638
 Built:        Thu Aug 18 05:33:38 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.12.1
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   23cf638
 Built:        Thu Aug 18 05:33:38 2016
 OS/Arch:      linux/amd64

Output of docker info:

Containers: 16
 Running: 3
 Paused: 0
 Stopped: 13
Images: 204
Server Version: 1.12.1
Storage Driver: devicemapper
 Pool Name: docker-253:1-916657-pool
 Pool Blocksize: 65.54 kB
 Base Device Size: 10.74 GB
 Backing Filesystem: xfs
 Data file: /dev/loop0
 Metadata file: /dev/loop1
 Data Space Used: 11.68 GB
 Data Space Total: 107.4 GB
 Data Space Available: 69.87 GB
 Metadata Space Used: 19.42 MB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 2.128 GB
 Thin Pool Minimum Free Space: 10.74 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: false
 Deferred Deletion Enabled: false
 Deferred Deleted Device Count: 0
 Data loop file: /var/lib/docker/devicemapper/devicemapper/data
 WARNING: Usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
 Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
 Library Version: 1.02.110 (2015-10-30)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: overlay bridge host null
Swarm: active
 NodeID: 5uzh00gzxmquexfcmurnq6ypm
 Is Manager: true
 ClusterID: 7vryc5c1s75o0jkttokhyo6dc
 Managers: 1
 Nodes: 4
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Heartbeat Tick: 1
  Election Tick: 3
 Dispatcher:
  Heartbeat Period: 5 seconds
 CA Configuration:
  Expiry Duration: 3 months
 Node Address: 10.133.13.82
Runtimes: runc
Default Runtime: runc
Security Options: apparmor seccomp
Kernel Version: 4.4.0-36-generic
Operating System: Ubuntu 16.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 12
Total Memory: 31.42 GiB
Name: dev-swarm-01
ID: 3FQW:TNXG:PUD2:FW4B:FU4Y:YS6E:NYCR:RGET:6SKY:LCOF:FW2G:UOE6
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Username: sebgieghost
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Insecure Registries:
 127.0.0.0/8

Additional environment details (AWS, VirtualBox, physical, etc.):
Ubuntu 16.04

@aluzzardi
Copy link
Member

Hey @sebgie,

The confusion comes from the fact that we have two set of labels:

  • Node labels (the ones you've been setting through docker node update)
  • Engine labels (the ones that you set when you start docker daemon with --label)

Label filtering in docker node ls is looking at engine labels rather than node labels.

We should probably revert to node label filtering rather than engine filtering

/cc @aaronlehmann @dperny @nishanttotla

@aluzzardi aluzzardi added this to the 1.13.0 milestone Oct 18, 2016
@aluzzardi aluzzardi added the priority/P2 Normal priority: default priority applied. label Oct 18, 2016
@allencloud
Copy link
Contributor

Hi, @aluzzardi
I think currently the way how docker deals the label is very important for users. I put forward a PR #28192 to include more description on docker node ls -f "label=a"

cezarsa added a commit to tsuru/tsuru that referenced this issue Nov 9, 2016
Label filtering in pool does not work as expected, daemon labels are
used instead of node labels. See
moby/moby#27231
@ghost
Copy link

ghost commented Mar 24, 2017

Any update on this? This ticket is labeled with the 1.13.0 milestone, but that has already gone out.

@allencloud
Copy link
Contributor

Yeah, as @aluzzardi mentioned. Currently swarmkit still takes engine labels as node filtering. I think we should support both. Open a pr moby/swarmkit#2062 to make it. PTAL

@cirocosta
Copy link
Contributor

cirocosta commented Apr 27, 2017

I was really feeling that I was crazy given that I couldn't get the list filtered haha. Nice to know about this issue and that there's already a PR that solves it.

In the mean time, I'm counting the number of nodes with a given label like this:

 docker node ls
ID                           HOSTNAME                                     STATUS  AVAILABILITY  MANAGER STATUS
88bd4sz9irxh1f5cylfeeft1c    ip-172-31-25-51.us-west-2.compute.internal   Ready   Active        
aa7c1vcg9a13hbdmjizyrcr9s    ip-172-31-13-77.us-west-2.compute.internal   Ready   Active        
e4rzm599p27hzrtrcaahpi1dd    ip-172-31-25-8.us-west-2.compute.internal    Ready   Active        
guc2m14qt53y9z769p6zlgh6k    ip-172-31-41-228.us-west-2.compute.internal  Ready   Active        
ibl03o334qrdmk7r0liwuyhhm    ip-172-31-44-53.us-west-2.compute.internal   Ready   Active        
motlc6ulkijxk1cnlk7x13bdr *  ip-172-31-35-137.us-west-2.compute.internal  Ready   Active        Leader

~ $ docker node update --label-add type=infra 88bd4sz9irxh1f5cylfeeft1c
88bd4sz9irxh1f5cylfeeft1c
~ $ docker node update --label-add type=test e4rzm599p27hzrtrcaahpi1dd
e4rzm599p27hzrtrcaahpi1dd

~ $ nodes=$(for node in $(docker node ls -q); do docker node inspect $node; done)
~ $ echo $nodes | jq '.[] | .Spec.Labels | select(has("type")) | .type'
"infra"
"test"

(github says that I unassigned @nishanttotla (????))

@thaJeztah thaJeztah removed this from the 1.13.0 milestone Mar 6, 2018
@thaJeztah thaJeztah added kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. exp/intermediate and removed priority/P2 Normal priority: default priority applied. labels Mar 6, 2018
@IvanBoyko
Copy link

Still not implemented?

@TheSchemm
Copy link

Funny that I just came across your comment @IvanBoyko, I am trying to set up a multiplatform infrastructure and I was wondering why my node labels weren't working! It would have been nice to know!

@Stephan-Walter
Copy link

The issue is still present and quite annoying, since it is not mentioned within the documentation. So it would be really great to at least update the official documentation. This is problem is more than two years old...

@olljanat
Copy link
Contributor

Current status looks to be that @allencloud have created PR moby/swarmkit#2062 about 1,5 years ago but it was not ever updated based on review so it was not merged and based on moby/swarmkit#2062 (comment) it looks to be that he will not continue that work.

So it would be best that someone else who have need for this one will continue that work. I have couple of other PRs which with I'm working on so I cannot look this on near future and we actually don't have big need for this as our server provisioning sets engine labels for all servers by default. If you need help you can contact me on Slack.

@Stephan-Walter you can create PR which updates documentation https://github.com/docker/docker.github.io / https://github.com/docker/cli (I have not time to investigate now which one those documents currently exists).

@ohperhaps
Copy link

Any update?

@custom20s
Copy link

Every developer goes for Kubernetes. That's how we get this 4 years old issue.

@olljanat
Copy link
Contributor

@custom20s honestly if you really need this feature then you should implement it. On nowadays DevOps world coding skill is coming more and more critical for Ops too and those are not able to do coding will be left behind.

Golang is quite simple to learn and I can help you getting started on Slack.

@thaJeztah
Copy link
Member

Looks like this was implemented in #37650, but the documentation was not updated to mention the node.label filter;

$ docker node update --label-add test swarm-test-04
swarm-test-04

$ docker node update --label-add test2 swarm-test-02
swarm-test-02


$ docker node ls --filter node.label=test
ID                            HOSTNAME        STATUS    AVAILABILITY   MANAGER STATUS   ENGINE VERSION
n41b2cijmhifxxvz56vwrs12q     swarm-test-04   Ready     Active                          20.10.0

$ docker node ls --filter node.label=test2
ID                            HOSTNAME        STATUS    AVAILABILITY   MANAGER STATUS   ENGINE VERSION
2lm9w9kbepgvkzkkeyku40e65     swarm-test-02   Ready     Active         Reachable        20.10.0

@thaJeztah
Copy link
Member

opened docker/cli#2951 to update docs and completion scripts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/swarm exp/intermediate kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. version/1.12
Projects
maintainers-session
  
Awaiting triage