Skip to content

run,commit: clean up parents of mount targets, too#6233

Merged
openshift-merge-bot[bot] merged 4 commits intocontainers:mainfrom
nalind:mount-targets
Jun 22, 2025
Merged

run,commit: clean up parents of mount targets, too#6233
openshift-merge-bot[bot] merged 4 commits intocontainers:mainfrom
nalind:mount-targets

Conversation

@nalind
Copy link
Member

@nalind nalind commented Jun 17, 2025

What type of PR is this?

/kind bug

What this PR does / why we need it:

When RUN requires us to create the target for a mountpoint, make note of it and any parent directories that needed to be created, clear them all out if they look basically the same after the command finishes, and make sure to filter them out when generating a layer diff or --output data.

The exceptions will be directories that the conformance tests confirm that BuildKit also leaves behind, though for compatibility with the classic builder, we have to make that conditional.

How to verify it

New conformance tests!
Updated integration tests!

Which issue(s) this PR fixes:

Related to #3525
Fixes #4242

Special notes for your reviewer:

Does this PR introduce a user-facing change?

`buildah build` should no longer leave traces of mount targets used for RUN instructions in built images.

@openshift-ci openshift-ci bot added kind/bug Categorizes issue or PR as related to a bug. approved labels Jun 17, 2025
@nalind nalind force-pushed the mount-targets branch 2 times, most recently from 43681bf to b83bf4d Compare June 17, 2025 21:20
nalind added 4 commits June 20, 2025 11:19
The TempVolumes field is used to track data that's specific to a Run()
call, and there can be more than one of those going at a time.  Merge
its data into the runMountArtifacts struct, which already keeps a list
of locations that we have to clean up in exactly the same way.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Always call the nested TarWriter's Flush() method after writing file
contents.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
When RUN requires us to create the target for a mountpoint, make note of
it and any parent directories that needed to be created, and clear them
all out if they look basically the same after the command finishes.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
When RUN requires us to create the target for a mountpoint, make note of
it and any parent directories that needed to be created, and filter them
out when generating a layer diff or --output data.

The exceptions will be directories that the conformance tests confirm
that BuildKit also leaves behind, though for compatibility with the
classic builder, we have to make that conditional.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Copy link
Collaborator

@flouthoc flouthoc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 20, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc, nalind

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

The pull request process is described here

Details 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

@rhatdan
Copy link
Member

rhatdan commented Jun 22, 2025

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jun 22, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 9bfdf2a into containers:main Jun 22, 2025
37 checks passed
@nalind nalind deleted the mount-targets branch June 23, 2025 13:44
TomSweeneyRedHat added a commit to TomSweeneyRedHat/podman that referenced this pull request Jul 23, 2025
As of Buildah v1.41, the return from the `podman diff` command
has changed due to how Buildah build is now ignoring mount
targets use for RUN instructions.  This was per a request from
the OSTREE group, and the associated PR is: containers/buildah#6233

Buildah v1.41 will be part of Podman v5.6

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
TomSweeneyRedHat added a commit to TomSweeneyRedHat/podman that referenced this pull request Jul 23, 2025
As of Buildah v1.41, the return from the `podman diff` command
has changed due to how Buildah build is now ignoring mount
targets use for RUN instructions.  This was per a request from
the OSTREE group, and the associated PR is: containers/buildah#6233

Buildah v1.41 will be part of Podman v5.6

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
TomSweeneyRedHat added a commit to TomSweeneyRedHat/podman that referenced this pull request Jul 23, 2025
As of Buildah v1.41, the return from the `podman diff` command
has changed due to how Buildah build is now ignoring mount
targets use for RUN instructions.  This was per a request from
the OSTREE group, and the associated PR is: containers/buildah#6233

Buildah v1.41 will be part of Podman v5.6

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators Sep 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

approved kind/bug Categorizes issue or PR as related to a bug. lgtm locked - please file new issue/PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

podman build injects empty /etc/resolv.conf into generated layers

3 participants