-
Notifications
You must be signed in to change notification settings - Fork 96
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
Container object uses wrong key path for ports on listed containers. #459
Comments
Assuming we want
[podman_client.containers.get(container.id) for container in podman_client.containers.list()] This obviously has the downside of processing overhead. I could also see this being unwanted behavior if someone explicitly wanted the schema returned by the
I'd be happy to implement the fix, but am relatively new to contributing to and using this project so I would be interested in hearing the thoughts/preferences of people more experienced before I settle on a particular type of solution. |
Thanks for the report. You can always ask and me or other maintainers will try to help you with reviews and advices. So, my quick take on the issue. Regarding your first comment
This can be solved by for container in podman_client.containers.list():
container.reload()
print(container.ports) We know that the reload call is expensive so we don't fetch the status while doing list. A possible solution to this is to implement the
This I am not sure why it happens but changing the payload needs to be done on podman side and it will break the API anyway. About your second comment. Options 1 and 2: I would avoid the post process for the reasons you said Option 3: This is probably the best approach Option 4: I would avoid since it would break the api Given that the issue seems to be the difference in What do you think @MattBelle ? |
The container object is currently pulling ports from
Container.NetworkSettings.Ports
:podman-py/podman/domain/containers.py
Lines 58 to 63 in 8a4cbf3
This works when you are inspecting an individual container like:
but fails when you get containers from a list operation eg:
Some brief playing around with the raw REST API makes it look like the object schema returned from those 2 endpoints differs dramatically. The correct spot in the list schema appears to be
Container.Ports
, but the format of the data would still need to be massaged if we want a coherent schema in the SDK.Single container inspect returns:
while the listed container payload is:
The text was updated successfully, but these errors were encountered: