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

Fix the locally non-existent image fails with AttributeError #408

Merged
merged 2 commits into from
Jul 24, 2024
Merged

Fix the locally non-existent image fails with AttributeError #408

merged 2 commits into from
Jul 24, 2024

Conversation

milanbalazs
Copy link
Contributor

The code for running a new container with an image that is not present locally tries to access the ImagesManager via self.client.images.
As self.client is an APIClient instance and not an instance of PodmanClient, an AttributeError occurs:

AttributeError: 'APIClient' object has no attribute 'images'

With this fix the PodmanClient object is used instead of APIClinet correctly.

A very minimal test code:

import podman

with podman.PodmanClient() as client:
    client.containers.run("docker.io/library/busybox:latest")

The above code failed with AttributeError before my fix. Currently it pulls the Image if it's not available in local and run the container.

Note:

  • I guess the other @cached_property methods also can be extended with my solution if it's needed. I have extended only the ContainersManager with podman_client argument.

It's fix for:
#378

The code for running a new container with an image that is not
present locally tries to access the ImagesManager
via self.client.images.
As self.client is an APIClient instance and not an instance of
PodmanClient, an AttributeError occurs:

AttributeError: 'APIClient' object has no attribute 'images'

With this fix the 'PodmanClient' object is used instead of
'APIClinet'.

Ticket:
#378

Signed-off-by: Milan Balazs <milanbalazs01@gmail.com>
Signed-off-by: Milan Balazs <milanbalazs01@gmail.com>
@rhatdan
Copy link
Member

rhatdan commented Jul 21, 2024

LGTM
@jwhonce @umohnani8 PTAL

@inknos inknos self-requested a review July 22, 2024 13:04
@umohnani8
Copy link
Member

LGTM

@inknos
Copy link
Contributor

inknos commented Jul 22, 2024

/lgtm

@jwhonce
Copy link
Member

jwhonce commented Jul 24, 2024

/approve

Copy link
Contributor

openshift-ci bot commented Jul 24, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: inknos, jwhonce, milanbalazs

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 35777ad into containers:main Jul 24, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants