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

libpod api will not return stats if the container is exited #15218

Closed
ttys3 opened this issue Aug 5, 2022 · 6 comments
Closed

libpod api will not return stats if the container is exited #15218

ttys3 opened this issue Aug 5, 2022 · 6 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@ttys3
Copy link
Contributor

ttys3 commented Aug 5, 2022

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

according to #14580

Non-running containers now report statistics via the podman stats

but I see the result for libpod api is : return nothing.

Steps to reproduce the issue:

  1. podman run --name demo -ti alpine sh -c 'echo hello'

  2. sudo podman stats --no-stream demo get:

ID            NAME        CPU %       MEM USAGE / LIMIT  MEM %       NET IO      BLOCK IO    PIDS        CPU TIME    AVG CPU %
9ef32ea2cb0e  demo        0.00%       0B / 0B            0.00%       0B / 0B     0B / 0B     0           0s          0.00%
  1. but libpod api get nothing:
sudo curl -vvv --unix-socket /run/podman/podman.sock http://d/v1.0.0/libpod/containers/demo/stats\?stream\=false
*   Trying /run/podman/podman.sock:0...
* Connected to d (/run/podman/podman.sock) port 80 (#0)
> GET /v1.0.0/libpod/containers/demo/stats?stream=false HTTP/1.1
> Host: d
> User-Agent: curl/7.84.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Api-Version: 1.41
< Libpod-Api-Version: 4.2.0-rc3
< Server: Libpod/4.2.0-rc3 (linux)
< X-Reference-Id: 0xc000014078
< Date: Fri, 05 Aug 2022 17:48:21 GMT
< Transfer-Encoding: chunked
< 
* Connection #0 to host d left intact

Describe the results you received:

nothing but a 200 code

Describe the results you expected:

zero stats just like the cli or it should return http error code ?

Additional information you deem important (e.g. issue happens only occasionally):

Output of podman version:

podman v4.1.1 and podman 4.2.0-rc3

Output of podman info:

(paste your output here)

Package info (e.g. output of rpm -q podman or apt list podman):

(paste your output here)

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)

Yes

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

@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Aug 5, 2022
ttys3 added a commit to ttys3/nomad-driver-podman that referenced this issue Aug 5, 2022
@rhatdan
Copy link
Member

rhatdan commented Aug 6, 2022

@mheon PTAL

@mheon
Copy link
Member

mheon commented Aug 6, 2022

We got a feature request in to allow this for the Docker-compat endpoints, so we enabled it there; never enabled it for the Libpod endpoints because nobody asked. Should be simple enough.

@mheon mheon self-assigned this Aug 6, 2022
@mheon
Copy link
Member

mheon commented Aug 6, 2022

Actually, this might be expected behavior... Let me verify against the Docker endpoints.

@mheon
Copy link
Member

mheon commented Aug 6, 2022

Verified against Docker, this is expected behavior. If the container is not started, we return nothing, same as Docker. Going to close given this.

@mheon mheon closed this as completed Aug 6, 2022
@ttys3
Copy link
Contributor Author

ttys3 commented Aug 7, 2022

the problem is, this change bring from cli, maybe related to #14580, I do not know.
it is a breaking change for libpod api.

previous version like podman v4.0.3, the cli will result in: Error: container state improper

and the libpod api will return:

< HTTP/1.1 409 Conflict
< Api-Version: 1.40
< Content-Type: application/json
< Libpod-Api-Version: 4.0.3
< Server: Libpod/4.0.3 (linux)
< X-Reference-Id: 0xc000518010
< Date: Sun, 07 Aug 2022 20:14:53 GMT
< Content-Length: 89
< 
{"cause":"container state improper","message":"container state improper","response":409}

which breaking exists code like:

https://github.com/hashicorp/nomad-driver-podman/blob/4efeb99d977c642a8aad85403f9b3f5d05256e1c/api/container_stats.go#L19-L30

which will cause nomad never got notified even the container exited with code 0

I checked the changelog v4.1.1:

Fixed a bug where the podman stats command could not be run on containers that were not running (it now reports all-0s statistics for Docker compatibility) (#14498).

the changelog says command, maybe more detailed (specific libpoad api and the compat api?).

Because this is a breaking change to the api.

@mheon
Copy link
Member

mheon commented Aug 8, 2022

It's a change, but I don't know if I would consider it a breaking change? It's a bugfix more than anything, given we did not match existing behavior / expected behavior vs Docker

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

No branches or pull requests

3 participants