Preserve POSIX absolute bind mount paths on Windows - #1518
Conversation
453db38 to
c439ba1
Compare
|
Shouldn't the proper fix be to switch to posix path module for any operations on a remote Linux machine? |
|
If I understand you correctly, you're suggesting that we check whether we're running in remote mode and, in that case, switch to BTW, I found how Docker Compose handles paths: https://github.com/compose-spec/compose-go/blob/ace34ebd2aae2913524151b2b02e67790c88983c/paths/unix.go#L38. So they check whether the path is absolute in either POSIX or Windows notation leaving it unchanged if it is. The corresponding Python code would be: is_abs = os.path.isabs(mount_src) or secondarypathisabs(mount_src)
if not is_abs and (os.name != 'nt' or ".sock" not in mount_src): |
Makes sense. I think we could do exactly as this, since this makes maximum compatibility with docker compose. Probably makes sense to introduce it as a function. |
885ebf8 to
0f4bfe3
Compare
On Windows, parse_short_mount() and assert_volume() unconditionally
run os.path.abspath() on bind mount sources. For a POSIX absolute
source like /etc/example, abspath() prepends the current drive,
producing C:\etc\example. As a result, when targeting a remote Linux
host, podman-compose fails with:
statfs /mnt/c/etc/example: no such file or directory
Skip the rewrite when the source is POSIX absolute on Windows.
Relative, ~, .sock, and drive paths are unaffected.
Fixes containers#1352
Signed-off-by: sgolev <53184912+sgolev@users.noreply.github.com>
0f4bfe3 to
58b6a93
Compare
On Windows,
parse_short_mount()andassert_volume()unconditionally runos.path.abspath()on bind mount sources. For a POSIX absolute source like/etc/example,os.path.abspath()prepends the current Windows drive, producingC:\etc\example. As a result, when targeting a remote Linux host, podman-compose fails with:The fix is to skip the rewrite when the source is POSIX absolute path on Windows. Relative,
~,.sock, and drive paths (C:\...) are unaffected.This PR fixes #1352.
As a side note,
assert_volume()doesn't work as intended when targeting a remote machine, because it ensures that directories exist on the local machine. I've tried to introduce minimal changes just to fix the Windows-to-remote-Linux workflow. When a POSIX absolute path is detected on Windows, both the rewrite and the local probe are skipped.