Skip to content

RUN: only use an overlay for --mount=type=bind,rw on overlay #6126

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

nalind
Copy link
Member

@nalind nalind commented Apr 15, 2025

What type of PR is this?

/kind bug

What this PR does / why we need it:

Only use an overlay for --mounts of type=bind,rw, where changes should be discarded, if the storage driver is overlay. Otherwise, make a temporary copy.

How to verify it

Updated CI to test {vfs|overlay} over {vfs|overlay}, which would have caught this.

Which issue(s) this PR fixes:

Should fix #5988.

Special notes for your reviewer:

Basically what #5988 (comment) suggested.

Does this PR introduce a user-facing change?

When not using overlay for storage, running `buildah run` or executing a `buildah build` RUN instruction with the `--mount=type=bind,rw` flag will now use a temporary copy to ensure that writes are discarded, instead of attempting to mount an overlay filesystem using the source location as a "lower".

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress kind/bug Categorizes issue or PR as related to a bug. labels Apr 15, 2025
Copy link
Contributor

openshift-ci bot commented Apr 15, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nalind

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

@nalind nalind force-pushed the overlay-copy branch 7 times, most recently from 6084d5f to b81b006 Compare April 17, 2025 18:20
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

@nalind nalind force-pushed the overlay-copy branch 2 times, most recently from 86b6879 to f0e6488 Compare April 23, 2025 21:57
@nalind nalind force-pushed the overlay-copy branch 6 times, most recently from 04b80e1 to e62f77c Compare April 25, 2025 20:55
@nalind nalind force-pushed the overlay-copy branch 7 times, most recently from dad02e0 to 5dd5313 Compare April 28, 2025 21:26
@nalind nalind marked this pull request as ready for review April 28, 2025 23:52
Copy link

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

I only gave this a quick skim and I don't know the code really, but FWIW looks sane to me.

@@ -118,6 +120,87 @@ func convertToOverlay(m specs.Mount, store storage.Store, mountLabel, tmpDir str
return mountThisInstead, overlayDir, nil
}

func makeTempCopy(m specs.Mount, tmpDir string, uid, gid int) (specs.Mount, string, error) {

Choose a reason for hiding this comment

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

This function seems like it could use a doc comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added one.

nalind added 10 commits May 2, 2025 10:04
Expand our task that runs the integration tests inside of a container
from running buildah-using-vfs-inside-podman-using-vfs and
buildah-using-overlay-inside-podman-using-overlay to also test vfs over
overlay, and overlay over vfs.

Signed-off-by: Nalin Dahyabhai <[email protected]>
Only use an overlay for --mounts of type=bind,rw, where changes should
be discarded, if the storage driver is overlay.  Otherwise, make a
temporary copy and use a bind mount to the copy.

Signed-off-by: Nalin Dahyabhai <[email protected]>
If we're forcing a mount using overlay, but we fail, and our chosen
upper directory is on overlay, try using fuse-overlayfs.

Signed-off-by: Nalin Dahyabhai <[email protected]>
Force the mount of the overlay in runSetupVolumeMounts() so that we can
take advantage of logic that tries to use fuse-overlayfs if we happen to
be on top of overlay, which would otherwise fail.

Signed-off-by: Nalin Dahyabhai <[email protected]>
Force the mount of the overlay in volumeCacheSaveOverlay(), and clean it
up in volumeCacheRestoreOverlay(), so that we can take advantage of
logic that tries to use fuse-overlayfs if we happen to be on top of
overlay, which would otherwise fail.

Signed-off-by: Nalin Dahyabhai <[email protected]>
Drop the conditional ,z that we were trying to add when testing the -v
flag with the "O" option, the combination of which is not allowed by
github.com/containers/common/pkg/parse.ValidateVolumeOpts().

Signed-off-by: Nalin Dahyabhai <[email protected]>
When grepping the mounts list for the root mount, also accept the entry
if "rw" is the only flag.

Signed-off-by: Nalin Dahyabhai <[email protected]>
If we're on overlayfs, we can't use the directory name that we'd like to
use as part of the test and expect things to succeed, even if we try to
work around it using fuse-overlayfs.

Signed-off-by: Nalin Dahyabhai <[email protected]>
If we're on overlayfs, we can't use the directory name that we'd like to
use as part of the test and expect things to succeed, even if we try to
work around it using fuse-overlayfs.

Signed-off-by: Nalin Dahyabhai <[email protected]>
When setting up a chroot using overlay, if the intended upper directory
is already on an overlayfs, mount a tmpfs onto it so that we can finish
setting up the chroot that's an overlayfs that we'll actually test in,
and copy the base image into the storage that it'll use.

Signed-off-by: Nalin Dahyabhai <[email protected]>
if test -x /usr/bin/fuse-overlayfs ; then
local storage_opts="overlay.mount_program=/usr/bin/fuse-overlayfs"
else
skip trying to use overlay on top of overlay, but fuse-overlayfs is not present
Copy link
Member

Choose a reason for hiding this comment

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

Possibly minor: Everywhere else I looked the reason is passed as a single argument to skip by quoting it. I'm unsure if passing multiple arguments like this also works, but for consistency it would be nice to quote it. But this is such a minor thing, please don't re-push only to fix this.

Comment on lines +310 to +319
matrix:
- env:
STORAGE_DRIVER: 'vfs'
- env:
STORAGE_DRIVER: 'overlay'
matrix:
- env:
NESTED_STORAGE_DRIVER: 'vfs'
- env:
NESTED_STORAGE_DRIVER: 'overlay'
Copy link
Member

Choose a reason for hiding this comment

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

I believe cirrus will happily accept this invalid YAML, but I believe hack/get_ci_vm.sh will puke on it because it uses python-yaml to parse the file. If this functionality is important, I believe something like the following would work:

Suggested change
matrix:
- env:
STORAGE_DRIVER: 'vfs'
- env:
STORAGE_DRIVER: 'overlay'
matrix:
- env:
NESTED_STORAGE_DRIVER: 'vfs'
- env:
NESTED_STORAGE_DRIVER: 'overlay'
matrix:
- env:
STORAGE_DRIVER: 'vfs'
NESTED_STORAGE_DRIVER: 'vfs'
- env:
STORAGE_DRIVER: 'overlay'
NESTED_STORAGE_DRIVER: 'vfs'
- env:
STORAGE_DRIVER: 'vfs'
NESTED_STORAGE_DRIVER: 'overlay'
- env:
STORAGE_DRIVER: 'overlay'
NESTED_STORAGE_DRIVER: 'overlay'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ERRO[0025] unlinkat /var/tmp/buildah2410054376/mounts3022885724/bind626918239: device or resource busy
4 participants