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

"Old" Containerfile being used in the builder machinery #1813

Open
git-hyagi opened this issue Nov 6, 2024 · 2 comments
Open

"Old" Containerfile being used in the builder machinery #1813

git-hyagi opened this issue Nov 6, 2024 · 2 comments
Labels

Comments

@git-hyagi
Copy link
Contributor

Describe the bug
If we push another version of a Containerfile to Pulp and try to build using it, the builder machinery will not use the latest version.

To Reproduce
Steps to reproduce the behavior:

pulp container repository create --name my-container-repo
pulp file repository create --name my-file-repo
cat<<EOF> /tmp/Containerfile
FROM quay.io/fedora/fedora-bootc:40
RUN dnf install -y hello
EOF
pulp file content upload --relative-path Containerfile --file /tmp/Containerfile --repository my-file-repo
curl ${CONTAINER_REPO}/build_image -F containerfile_name=Containerfile -F build_context={FILE_REPO}versions/1/

echo "RUN dnf install -y vim" >> /tmp/Containerfile
pulp file content upload --relative-path Containerfile --file /tmp/Containerfile --repository my-file-repo
curl ${CONTAINER_REPO}/build_image -F containerfile_name=Containerfile -F build_context={FILE_REPO}versions/2/

The build task will run, but a new manifest will not be created after these steps.

pulp container content -tmanifest list

Additional context
As a workaround, instead of using the same filename, uploading the Containerfile with a different name would work.

maybe modifying the line:

for content_artifact in content_artifacts.select_related("artifact").iterator():

to:

            for content_artifact in content_artifacts.select_related("artifact").order_by("pulp_created").iterator():

would fix this issue because the containerfile_artifact would be overwritten with the latest version:

if content_artifact.relative_path == containerfile_name:
containerfile_artifact = content_artifact.artifact

@git-hyagi git-hyagi added the Issue label Nov 6, 2024
@lubosmj
Copy link
Member

lubosmj commented Nov 6, 2024

How about focusing on this query instead?

content_artifacts = ContentArtifact.objects.filter(
content__pulp_type="file.file", content__repositories__in=[build_context_pk]
).order_by("-content__pulp_created")

@mdellweg
Copy link
Member

mdellweg commented Nov 8, 2024

Wait a minute. A pulp-file repository should only be able to contain a single file per path. That should already solve any abbiguity. Can you confirm that uploading a second "Containerfile" will indeed replace the first one? Sorting anything by pulp_created here is by no means a solution to the issue, because the content added to the repository by the second upload could already have been in pulp for a very long time...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants