Skip to content

Use the WSL convention for the windows machines default volumes#2100

Merged
openshift-merge-bot[bot] merged 1 commit intocontainers:mainfrom
l0rd:windows-machines-default-volumes
Aug 6, 2024
Merged

Use the WSL convention for the windows machines default volumes#2100
openshift-merge-bot[bot] merged 1 commit intocontainers:mainfrom
l0rd:windows-machines-default-volumes

Conversation

@l0rd
Copy link
Member

@l0rd l0rd commented Jul 25, 2024

Currently on Windows, volumes are mounted differently based on the provider:

  • WSL automatically mounts the main drive C:/ under /mnt/c on every Linux VM
  • For HyperV instead, podman mounts C:\Users\name under /Users/name

Issues like this one are the consequence of such behavior.

With this PR getDefaultMachineVolumes() is updated to be consistent with WSL default behavior. That means that on both WSL and HyperV machines, the default volumes will be the %userprofile% drive (e.g. C:/) mounted under /mnt/ (e.g. /mnt/c).

The old Hyper-V mount is still supported. Users can still use the notation podman run -v /Users when the provider is Hyper-V although the notation podman run -v C:\Users should be preferred.

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

This is likely the right thing but it also a breaking change as hyper V users might depend on the current paths and I am not sure how we could deal with that.

@l0rd
Copy link
Member Author

l0rd commented Jul 25, 2024

This is likely the right thing but it also a breaking change as hyper V users might depend on the current paths and I am not sure how we could deal with that.

This is very true but volumes, with the default mount config, were kind of broken on Hyper-V.

For example:

podman run -v C:\Users\username\folder:/test fedora

fails to start.

So I am wondering, how many podman users are using Hyper-V with the default mount config? Not a lot I guess. But the more we wait there more there will be.

And for those that have a custom mount config (as suggested in the issue for example), this PR doesn't affect them.

@Luap99
Copy link
Member

Luap99 commented Jul 25, 2024

podman run -v /Users/username/folder:/test fedora

But this should work with the current default I assume? And if we have users using that we break them.

I mean overall the number of hyperV users is most likely very small compared to WSL so maybe it is the right thing to do it now to make the volume behaviour consistent and just let people deal with it. Although is there any way we can make it backwards compatible?

Maybe we could add two mounts C:\Users\name:/User/name and C:\Users\name:/mnt/c/Users/name? Or we could configure the machine to have symlink from the old path to the new one but that would require a bunch of extra code.

@l0rd
Copy link
Member Author

l0rd commented Jul 25, 2024

podman run -v /Users/username/folder:/test fedora

But this should work with the current default I assume? And if we have users using that we break them.

Yes you are correct. That works and users that use that will get broken

I mean overall the number of hyperV users is most likely very small compared to WSL so maybe it is the right thing to do it now to make the volume behaviour consistent and just let people deal with it. Although is there any way we can make it backwards compatible?

Maybe we could add two mounts C:\Users\name:/User/name and C:\Users\name:/mnt/c/Users/name? Or we could configure the machine to have symlink from the old path to the new one but that would require a bunch of extra code.

I have tested adding both mount configs (C:\Users\username:/Users/username and C:\:/mnt/c) and, with that, both formats work. And the code is still pretty simple.

That's not an obvious choice. Do we want to force users to move to a consistent volume format or should we keep maintaining the support for those two inconsistent formats on windows? Considered that Hyper-V is still not widely used I would lean towards the first option. But I am happy to update the PR if the consensus is for the second option. @n1hility @baude what's your opinion on that?

@l0rd
Copy link
Member Author

l0rd commented Jul 29, 2024

I have pushed a commit with the alternative approach (keeping the old hyper-v default mount and adding a new WSL-consistent mount) to this branch l0rd@2dfaccc.

@n1hility
Copy link
Member

I think its fine to keep support for both formats you can always deprecate one and remove the code later.

Copy link

@jeffmaury jeffmaury left a comment

Choose a reason for hiding this comment

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

Shouldn't we scan all local drives (C: D: ...) ?

@baude
Copy link
Member

baude commented Jul 30, 2024

im ok with the option to support both ...

@l0rd l0rd force-pushed the windows-machines-default-volumes branch from 0f3ba1a to 0282f33 Compare July 30, 2024 12:50
@l0rd
Copy link
Member Author

l0rd commented Jul 30, 2024

@n1hility @baude @Luap99 thank you for your review. I have updated the PR so that both notations are supported on Hyper-V (-v /Users/ and -v C:\Users\). The unit test is updated to test both. Tests are passing.

@jeffmaury thank for looking at this too. This PR addresses an Hyper-V / WSL inconsistency. Supporting -v <arbitrary-drive>:/ is out of scope and worth a (separate) discussion.

Comment on lines +46 to +47
// behavior where the host %SystemDrive% (e.g. C:\) is automatically mounted
// in the guest under /mnt/ (e.g. /mnt/c/)
Copy link
Member

Choose a reason for hiding this comment

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

The comment doesn't quite match the code, we mount the drive where the users homedir is located.
I don't know if there is a way for a homedir to be on a different disk compared to C: (%SystemDrive%) in practise (at least super unlikely) so not really that important I guess but maybe we should actually lookup the SystemDrive env?

Copy link
Member Author

Choose a reason for hiding this comment

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

Technically the drive of %USERPROFILE% can be different from %SYSTEMDRIVE%. But I still think we should mount %USERPROFILE% drive rather than %SYSTEMDRIVE% as user files are typically there. I have updated the comment.

)

func TestGetDefaultMachineVolumes(t *testing.T) {
t.Parallel()
Copy link
Member

Choose a reason for hiding this comment

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

this is incompatible with setenv so you need to remove this.

},
} {
for _, env := range tc.envs {
os.Setenv(env[0], env[1])
Copy link
Member

Choose a reason for hiding this comment

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

use t.Setenv() then go should rightfully error out and tell you using setenv with parallel is not supported.

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
@l0rd l0rd force-pushed the windows-machines-default-volumes branch from 0282f33 to 2a99bbd Compare July 30, 2024 17:34
@l0rd
Copy link
Member Author

l0rd commented Jul 30, 2024

@Luap99 thank you for the review. I have updated the PR taking into account your feedback.

Copy link
Member

@Luap99 Luap99 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 Jul 30, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: l0rd, Luap99

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

@l0rd
Copy link
Member Author

l0rd commented Aug 6, 2024

@baude @containers/podman-maintainers PTAL

@rhatdan
Copy link
Member

rhatdan commented Aug 6, 2024

@baude @n1hility @ashley-cui PTAL

@baude
Copy link
Member

baude commented Aug 6, 2024

/lgtm

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants