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

Containers stats is broken in Docker-py 6.1.0 #3118

Closed
nicolargo opened this issue May 6, 2023 · 2 comments · Fixed by #3120
Closed

Containers stats is broken in Docker-py 6.1.0 #3118

nicolargo opened this issue May 6, 2023 · 2 comments · Fixed by #3120

Comments

@nicolargo
Copy link

Look like Docker-Py breaks the API to retrieve stats from containers.

With Docker 6.0.1 (on Ubuntu 22.04):

>>> import docker
>>> c = docker..from_env()
>>> for i in c.containers.list():
...     i.stats(decode=True)
... 
<generator object APIClient._stream_helper at 0x7f236f354eb0>

With Docker 6.1.0:

>>> import docker
>>> c = docker..from_env()
>>> for i in c.containers.list():
...     i.stats(decode=True)
... 
Never return anything...

Additional information:

$ cat /etc/os-release 
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

$ docker version
Client: Docker Engine - Community
 Version:           23.0.1
 API version:       1.42
 Go version:        go1.19.5
 Git commit:        a5ee5b1
 Built:             Thu Feb  9 19:46:56 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          23.0.1
  API version:      1.42 (minimum version 1.12)
  Go version:       go1.19.5
  Git commit:       bc3805a
  Built:            Thu Feb  9 19:46:56 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.19
  GitCommit:        1e1ea6e986c6c86565bc33d52e34b81b3e2bc71f
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0

Source: nicolargo/glances#2366

@nicolargo
Copy link
Author

nicolargo commented May 6, 2023

Corrected by forcing stream=True. Does the default value for stream change between Docker-Py 6.0.1 and 6.1.0 ?

>>> import docker
>>> c = docker..from_env()
>>> for i in c.containers.list():
...     i.stats(stream=True, decode=True)
... 
Works !

===

EDIT: My bad !

I use the version 6.0.1 on my host, it is why it is working !

So the issue is not resolved by the use of stream=True :(

@RazCrimson
Copy link
Contributor

RazCrimson commented May 6, 2023

Just to note I can't get the stats API working when even passing the stream=True .

The above PR should fix the issue.

image

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 a pull request may close this issue.

2 participants