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 for an exact match on service name no longer works #46341

Open
haxwithaxe opened this issue Aug 27, 2023 · 4 comments
Open

Filtering for an exact match on service name no longer works #46341

haxwithaxe opened this issue Aug 27, 2023 · 4 comments
Labels
area/api area/swarm kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. status/0-triage version/24.0

Comments

@haxwithaxe
Copy link

Description

I'm using the python API but this seems like something happening on the other side of the docker socket.
Filtering for an existing service (named 'match_me') by it's name with match_me as the criteria I get the service. Filtering for the same service by it's exact name with ^match_me$ as the criteria I get nothing.

At least as of about 6 months ago I'm fairly certain I would have gotten the service. At that time I manually tested the bit of my code that takes advantage of that and I'm 100% certain it worked.

There is no problem filtering containers just services.

Reproduce

This assumes the host is part of a docker swarm.

import docker
cli = docker.from_env()
cli.services.create(
        'alpine:latest', 
        name='match_me',
        command='''/bin/sh -c 'while true; do sleep 600; done' '''
)
print(cli.services.list(filters={'name': 'match_me'}))
print(cli.services.list(filters={'name': '^match_me$'}))

The above prints this when run:

[<Service: w6p9duqis7hx>]
[]

Expected behavior

The service filters should respect regex.
More concretely the output of the script in steps to reproduce should be two identical lines (assuming there is only one service with 'match_me' in it's name).

[<Service: w6p9duqis7hx>]
[<Service: w6p9duqis7hx>]

docker version

Client: Docker Engine - Community
 Version:           24.0.5
 API version:       1.43
 Go version:        go1.20.6
 Git commit:        ced0996
 Built:             Fri Jul 21 20:35:18 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          24.0.5
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.6
  Git commit:       a61e2b4
  Built:            Fri Jul 21 20:35:18 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.22
  GitCommit:        8165feabfdfe38c65b599c4993d227328c231fca
 runc:
  Version:          1.1.8
  GitCommit:        v1.1.8-0-g82f18fe
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client: Docker Engine - Community
 Version:    24.0.5
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.2
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.20.2
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 6
  Running: 3
  Paused: 0
  Stopped: 3
 Images: 47
 Server Version: 24.0.5
 Storage Driver: zfs
  Zpool: tank
  Zpool Health: ONLINE
  Parent Dataset: tank/var-lib-docker
  Space Used By Parent: 15015874560
  Space Available: 276434272256
  Parent Quota: no
  Compression: zstd
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: active
  NodeID: e256kxpwmyx613cpcjaf3y4z5
  Is Manager: true
  ClusterID: mrnowi9jvzyueowqd1ocr0lzk
  Managers: 5
  Nodes: 5
  Default Address Pool: 172.19.0.0/16  
  SubnetSize: 24
  Data Path Port: 4789
  Orchestration:
   Task History Retention Limit: 5
  Raft:
   Snapshot Interval: 10000
   Number of Old Snapshots to Retain: 0
   Heartbeat Tick: 1
   Election Tick: 10
  Dispatcher:
   Heartbeat Period: 5 seconds
  CA Configuration:
   Expiry Duration: 3 months
   Force Rotate: 0
  Autolock Managers: false
  Root Rotation In Progress: false
  Node Address: 192.168.10.203
  Manager Addresses:
   192.168.10.14:2377
   192.168.10.203:2377
   192.168.10.54:2377
   192.168.10.59:2377
   192.168.10.8:2377
 Runtimes: io.containerd.runc.v2 nvidia runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 8165feabfdfe38c65b599c4993d227328c231fca
 runc version: v1.1.8-0-g82f18fe
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.15.0-79-generic
 Operating System: Ubuntu 22.04.3 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 15.52GiB
 Name: cricket
 ID: POCH:ZWAM:7UPP:42AZ:A44V:UUB4:LZZZ:FZJS:GBC5:PB2G:PZ32:IPEP
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: haxwithaxe
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional Info

Maybe I'm doing something wrong but I can't find anything. I'm writing tests so I have direct access to the service object I'm searching for from the beginning. I'm using an f-string to create the filter criteria f'^{service.name}$' so it isn't like there is trailing white space or typos making it not match. I take well to RTFM as long as there is a rough pointer to where or what in the FM I should be reading. Thank you for your time.

@haxwithaxe haxwithaxe added kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. status/0-triage labels Aug 27, 2023
@sam-thibault
Copy link
Contributor

Do you know which version you were running before?

@haxwithaxe
Copy link
Author

Unfortunately I don't know what version of docker I was using. I use docker-ce from the docker apt repo (both Debian and Ubuntu) and the last time I ran the relevant tests and they passed was January 31, 2023. I haven't run those tests again until a few days ago so there's not much granularity :/
I can tell you the docker python module I was using was 6.0.1 and currently I'm using 6.1.3.

@haxwithaxe
Copy link
Author

I just did some digging and based on release date it looks like version 20.10.23 is the most recent possible release that I could have been using.
If you have gotten to the point where you can't reproduce this I'd like to know so I can try to write my way around it until I stop hallucinating. :)

haxwithaxe pushed a commit to haxwithaxe/certdeploy that referenced this issue Sep 17, 2023
@haxwithaxe
Copy link
Author

Just an update. This is still an issue for me in 24.0.6, build ed223bc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api area/swarm kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. status/0-triage version/24.0
Projects
None yet
Development

No branches or pull requests

2 participants