Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

macOS: resolve volume source symlinks to fix /tmp mounts#27622

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Banana-Cultist wants to merge2 commits intocontainers:main
base:main
Choose a base branch
Loading
fromBanana-Cultist:macos-tmp-vol-share

Conversation

@Banana-Cultist
Copy link

This PR fixes an issue where mounting volumes from directories that are symbolic links on the host (specifically /tmp on macOS) would fail or result in mounting the wrong directory inside the VM.

On macOS, /tmp is a symlink to /private/tmp. When a user runs podman run -v /tmp/foo:/mnt ..., the Podman client sends the path /tmp/foo to the Linux VM. The Linux VM has its own /tmp directory while also mounting /private from the host. This results in a statfs error or the container mounting the VM's local /tmp instead of the user's intended host directory (/private/tmp).

This PR updates the volume spec generation logic in pkg/specgen to resolve symbolic links for absolute host paths on macOS before the spec is sent to the backend. This ensures that /tmp/foo is converted to /private/tmp/foo, which correctly maps to the shared file system mount inside the Podman machine.

A new unit test TestResolveVolumeSourcePathTmpSymlink has been added in pkg/specgen.

I also manually verified the fix using apodman-remote binary built from this branch:

Reproduction Command:

mkdir -p /tmp/test-vol/datatouch /tmp/test-vol/data/hello.txt./bin/darwin/podman run --rm -v /tmp/test-vol/data:/mnt alpine ls /mnt

Before:
Error: statfs /tmp/test-vol/data: no such file or directory

After:
hello.txt

Fixes#27468

Checklist

Ensure you have completed the following checklist for your pull request to be reviewed:

  • Certify you wrote the patch or otherwise have the right to pass it on as an open-source patch by signing all
    commits. (git commit -s). (If needed, usegit commit -s --amend). The author email must match
    the sign-off email address. SeeCONTRIBUTING.md
    for more information.
  • Referenced issues usingFixes: #00000 in commit message (if applicable)
  • Tests have been added/updated (or no tests are needed)
  • Documentation has been updated (or no documentation changes are needed)
  • All commits passmake validatepr (format/lint checks)
  • Release note entered in the section below (orNone if no user-facing changes)

Does this PR introduce a user-facing change?

Fixed an issue on macOS where volume mounts from `/tmp` (or other symlinked host directories) failed to mount the correct host path.

Signed-off-by: Bruce Fan <brucexfan@gmail.com>
Signed-off-by: Bruce Fan <brucexfan@gmail.com>
@openshift-ci
Copy link
Contributor

[APPROVALNOTIFIER] This PR isNOT APPROVED

This pull-request has been approved by:Banana-Cultist
Once this PR has been reviewed and has the lgtm label, please assignluap99 for approval. For more information seethe Code Review Process.

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

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

Copy link
Member

@Honny1Honny1 left a comment

Choose a reason for hiding this comment

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

I have just one nit about the test. Also, I realized that this issue also impacts thelocal API, but it is unrelated to this PR. I will create an issue for that.

)

func TestResolveVolumeSourcePathTmpSymlink(t *testing.T) {
dir, err := os.MkdirTemp("/tmp", "podman-vol-")
Copy link
Member

Choose a reason for hiding this comment

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

Uset.TempDir() for automatic cleanup. According to theimplementation, this callsMkdirTemp using the default temporary path derived from theTMPDIR environment variable (MkdirTemp,TempDir() string)). You can uset.Setenv to force this to/tmp.

Suggested change
dir,err:=os.MkdirTemp("/tmp","podman-vol-")
dir:=t.TempDir()

Copy link
Member

@Luap99Luap99 left a comment

Choose a reason for hiding this comment

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

Thanks, but I am not sure this make sense.

First of all this changes the behavior for macos only making it rather confusing if you compare it to podman-remote on linux.

But second, most importantly this is a a breaking change. In general there is not direct relation between the path on the client and on the server. The actual mounts happen server side so if we resolve the path on the client it means it is impossible to mount/tmp/somedir on the server because the client always resolves it first.
On the other hand if we don't resolve like currently we pass the path as is and it works just fine. And if a users wants to resolve the link they can just do it themselves before calling podman.
Our docs never claim to mount /tmp with podman machine, we do mount /private so I think saying we must fix /tmp mounts is wrong. There is also no guarantee that the symlink target exists on the server.

As such I would recommend to close the issue as wontifx but I am interesting in@baude@mheon@l0rd and@ashley-cui opinions on this.

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

Reviewers

@Honny1Honny1Honny1 requested changes

@Luap99Luap99Luap99 requested changes

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

MacOS volume sharing located at /tmp/<dir> fails with "Error: statfs /tmp/<dir>: no such file or directory"

3 participants

@Banana-Cultist@Honny1@Luap99

[8]ページ先頭

©2009-2025 Movatter.jp