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

podman_image don't rebuilt the image if I set a new containerfile #646

Open
CyberFox001 opened this issue Sep 23, 2023 · 4 comments
Open
Labels
bug Something isn't working

Comments

@CyberFox001
Copy link
Contributor

/kind bug

Description

If I:

  • Use podman_image, in a playbook, to built an image from a Containerfile
  • Run the playbook
  • Specify another Containerfile and re-run the playbook

The image is not built again.

But the requested image is different because the Containerfile is different. So the image should be rebuild in this case.

Steps to reproduce the issue:

  1. Create a playbook and use podman_image with state to build and build.file to a Containerfile

  2. Run the playbook

  3. Modify the playbook to set podman_image.build.file to another Containerfile

  4. Run the playbook again

Describe the results you received:

The image is not build again.

Describe the results you expected:

The image should be build again.

Version of the containers.podman collection:

1.10.2

Output of ansible --version:

ansible [core 2.15.3]

Output of podman version:

4.3.1

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

podman/stable,now 4.3.1+ds1-8+b1 amd64  [installé]
@sshnaidm sshnaidm added the bug Something isn't working label Sep 27, 2023
@sshnaidm
Copy link
Member

I think it's impossible to know if it's a different Containerfile or same Containerfile with different content, or just same. So it's better to force building if any Containerfile is set. You can use force option.
I can set it as a default if Containerfile is set, but need to think if it doesn't break others.

@CyberFox001
Copy link
Contributor Author

Yes. I have inspected an image created by podman_image and I don't see any info that can be used to know if we use 2 different Containerfile.

Maybe we can add a new parameter to podman_image, example podman_image.build.record_containerfile_hash, that will save the hash of the used Containerfile to the built image. Maybe as a label.

So, next time we run podman_image, it can compare the hash saved in the image with the one from the given Containerfile. If it's different, the image is rebuilt.

@sshnaidm
Copy link
Member

sshnaidm commented Oct 2, 2023

That's an interesting idea! I think we can use "annotations" for that? It's exactly for image metadata info.
I think we can add to annotations every Containerfile/Dockerfile hash and if there is an existing hash, then compare it. If no existing hash - then go by the standard procedure.
Would you like to create a patch?

@CyberFox001
Copy link
Contributor Author

I would like to. 😃

But for now I don't have enough time because of school.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants