Skip to content

Add a workaround for using mount without privileges, re-enable rootless tests in CI#6933

Open
nalind wants to merge 7 commits into
podman-container-tools:mainfrom
nalind:rootless-tests
Open

Add a workaround for using mount without privileges, re-enable rootless tests in CI#6933
nalind wants to merge 7 commits into
podman-container-tools:mainfrom
nalind:rootless-tests

Conversation

@nalind

@nalind nalind commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

  • Add a buildah mount-sshfs workaround for not being able to buildah mount when not root.
  • Rework integration tests to use buildah mount-sshfs when run by a UID other than 0, and working around the workaround's limitations (chiefly: avoid buildah run/add/copy while the filesystem is mounted).
  • Re-enable rootless tests in CI.

How to verify it

New and updated integration tests!

Which issue(s) this PR fixes:

This is mainly about re-enabling tests in CI. We weren't really testing with overlay in rootless scenarios before.

Special notes for your reviewer:

The new commands are marked as hidden.
This doesn't add new library APIs.

Does this PR introduce a user-facing change?

Adds undocumented `buildah serve-sftp` and `buildah sshfs-mount` commands.  Don't tell anyone.

@nalind nalind changed the title WIP: add a workaround for using mount without privileges, re-enable rootless tests in CI Add a workaround for using mount without privileges, re-enable rootless tests in CI Jun 29, 2026
@nalind nalind marked this pull request as ready for review June 29, 2026 14:07

@Luap99 Luap99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, I am a bit conflicted about this.

On the one hand I see how this helps us with testing but on the other side do we really want to ship and fully support these commands for general use?

I mean 900 lines is not that bad but it also is not exactly straight forward code and then well we take on a new sftp dep which is like 10k lines as well. That feels a bit much for just testing, though I guess the reason why documents them is because they can also be useful to some users so I can see the point.

Since you are the main maintainer here and likely already considered all this when you write the code I guess I am cool with it.

CI wise LGTM, I did not review the 900 lines of sftp.go so far though

@TomSweeneyRedHat

Copy link
Copy Markdown
Contributor

LGTM
@ddarrah WDYT?

@TomSweeneyRedHat

Copy link
Copy Markdown
Contributor

Pinging Dave mostly to make sure this is tracked for RHEL if we move forward with this.

@nalind

nalind commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

I keep meaning to bring up the sshfs/sftp part of it at a meeting to get a better feel for whether or not we want to include that part of this, since it has limitations if you try to use that outside of test cases.

@nalind

nalind commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Been kicking the idea around since https://redhat.atlassian.net/browse/RUN-1457, finally had a reason to look into it.

@Luap99

Luap99 commented Jul 13, 2026

Copy link
Copy Markdown
Member

I think it is certainly a nice use case for the tests. Maybe hiding the commands and label it unsupported on RHEL would help to reduce or maintenance load.

@ddarrah

ddarrah commented Jul 14, 2026

Copy link
Copy Markdown

It's a nice approach. Do I understand correctly that the pipeloop is self contained in the test directory, and that sshfs is already a part of RHEL? If not, I see no issue with installing it simply for the tests from EPEL. We pull BATS in to run tests. I just don't want any part of a new RHEL package, especially just to run tests.

@nalind

nalind commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

The pipeloop helper is standalone, but AFAIK sshfs is not a part of RHEL or EPEL.

We'll need something that we can use to test the serve-sftp command
without also testing our management of an sshfs mountpoint.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
nalind added 2 commits July 14, 2026 10:48
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This is how we run tests in CI, and we would like timing information there.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
nalind added 4 commits July 14, 2026 10:58
Add an undocumented CLI command which serves the contents of a container
or image over stdio using the SFTP protocol.  The intent is to be able
to slot this in where the sshfs(1) documentation suggests running the
OpenSSH SFTP server subsystem binary to share a directory's contents
with a remote shell session.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Add an undocumented CLI command which pairs "buildah serve-sftp" with
the copy of "sshfs" that we launch, piping the output of each to the
input of the other, as suggested in sshfs(1).

Because "buildah mount-sshfs" doesn't set up a user namespace the way
that "buildah unshare" and most of our other CLI commands do, the copy
of "sshfs" that it runs will run outside of any user namespaces, while
the "buildah serve-sftp" bits will of course run inside of a user
namespace if one would normally be created for the invoking user.

Not being run inside of a user's user namespace means that neither
"buildah mount-sshfs", nor by extension, "buildah umount-sshfs", can be
guaranteed to be able to directly examine storage, so we also add an
extra, hidden, CLIs ("buildah find-data-dir" and "buildah
list-sshfs-mount-dirs") that can be called to locate where the userdata
directory and would-be mountpoints for a given container or image ID
are.

We have "buildah umount-sshfs" exec "buildah find-data-dir" to look up
the userdata directory for something which was previously mounted by
"buildah mount-sshfs" and reconstruct the location of the mountpoint so
that the experience of using "buildah mount-sshfs" and "buildah
umount-sshfs" will more closely match that of "buildah mount" and
"buildah umount".

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Previously, if the tests were run as a non-root user, we'd always run
"buildah mount" under "buildah unshare" to avoid error messages about
how it wasn't expected to work.  This, however, only ever "worked" for
the vfs storage driver, which didn't actually mount or unmount
filesystems.

Drop that and instead use a run_buildah_mount wrapper function that
calls either `buildah mount` or `buildah mount-sshfs`, depending on the
current UID.  Add a corresponding run_buildah_umount wrapper function,
and use it instead of `buildah unmount` or `buildah umount`.  For the
most part, this is merely mechanical replacement.

Call run_buildah_umount() before `buildah rm` in a number of tests: the
umount-with-detach that the container removal logic uses doesn't provide
enough time for the mountpoint to become idle before it then attempts to
remove it.

The "copy-from-image" test was actually using `buildah add`, so move it
from copy.bats to add.bats and add a workalike in its place.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
@nalind

nalind commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

The pipeloop helper is standalone, but AFAIK sshfs is not a part of RHEL or EPEL.

My mistake: I was looking for a package named "sshfs", not "fuse-sshfs". It's been noted elsewhere that fuse-sshfs is in EPEL 9 and 10.

Changed the new commands to be undocumented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants