-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
path/filepath: EvalSymlinks of a directory which is mapped from volumeID (instead of drive letter) does not work #39786
Comments
I found a way to use Powershell command to workaround this issue in kubernetes code. |
EDIT: Related: #39785 @gopherbot add OS-Windows |
Change https://golang.org/cl/241278 mentions this issue: |
Man I am so annoyed about this for years now that I learned Go just to fix this - I've written about 100 lines total now... |
Consider weighing in on #40104 to see issues like this finally be resolved once and forever. |
I tried reproducing your problem on current tip (it will be part of go1.15 soon), and I cannot. In particular, I tried an existing Go library test, that does exactly what you are describing in this issue.
Can you, please, try to run this test yourself (you will have to be the Administrator) and tell us, if it fails or passes? If you think your situation is different, then, please, provide complete reproduction steps, and not just vague description. Thank you. Alex |
This is the code Alex refers to: https://github.com/golang/go/blob/master/src/path/filepath/path_windows_test.go#L538 @alexbrainman according to the kubernetes issue linked above, there's no drive letter assigned to this volume. |
How do I reproduce this? The issue above asks me to use mklink command. So I did. Alex |
I believe you create a VHDX and don't assign it a drive letter. Then |
Yes, @networkimprov is correct. This is a very common configuration on Windows that go should not pre-empt with bugs. The PowerShell: $vhd = New-VHD -Path Test.vhdx -SizeBytes 3MB -Fixed
$vhd | Mount-VHD
$vhd = Get-VHD Test.vhdx # refresh IsAttached etc
$vhd | Get-Disk | Initialize-Disk -PartitionStyle GPT
$part = $vhd | Get-Disk | New-Partition -UseMaximumSize -AssignDriveLetter:$false
$vol = $part | Format-Volume -FileSystem NTFS
cmd /c mklink /j Test $vol.Path
[System.IO.File]::WriteAllText("$PWD\Test\Dockerfile", "FROM scratch")
docker build Test
# Cleanup
Dismount-Vhd Test.vhdx
rmdir Test
del Test.vhdx The output from docker is this time:
|
This fails, I believe about exactly the same, configuring Storage Spaces and wanting to put docker on a |
I don't know if my go is actually patched with #40095... Your output will be different in that case. This might be bug no. 2 on this code path, seeing that go somehow needed to add an absolute path the the current working directory which it should have replaced resolving the junction at "$PWD\Test". |
Sorry @jingxu97, I didn't get any notifications from this somehow. Anyway yes, the test passes, but obviously they are very incomplete:
|
It is and I tested my For one it by now has So this fix is partial. Obviously I also did not add any tests, changing only one file. |
This is the culprit
I'm not sure how After running (Get-VHD .\\Disk.vhdx) | Get-Disk | Get-Partition | Remove-PartitionAccessPath -AccessPath C:\Docker\Mount\ I run in yet another problem, although I like the first part of it -
|
Removing the Running
my fix becomes applicable.
|
Finally, to reproduce against the original issue text above:
|
This fix is complete for the situation that is described. |
You seems to be talking to yourself. I am still confused where are the repro steps. Could you point me to the steps, please? Thank you. Alex |
@alexbrainman use this powershell script to make a vhdx and symlink, then pass the symlink to filepath.EvalSymlinks.
Related bug: #40176 |
I find that the feature names differ for desktop and server. Also on server, the command I gave previously isn't enough, since the PowerShell functionality is not actually a subcomponent of Hyper-V itself. For Desktops: PS> Get-WindowsOptionalFeature -Online -FeatureName *Hyper-V* | ft
PS> Enable-WindowsOptionalFeature Microsoft-Hyper-V-All -Online # will install Microsoft-Hyper-V-Hypervisor It could be possible that Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Management-PowerShell, Microsoft-Hyper-V-Services On server, the feature installation is unfortunately less detailed such that the provider services and Hyper-V cannot be selected separately, as mentioned. PS> Install-WindowsFeature Hyper-V -Restart
PS> Install-WindowsFeature Hyper-V-PowerShell
PS> Get-WindowsFeature -Name *Hyper-V*
Display Name Name Install State
------------ ---- -------------
[X] Hyper-V Hyper-V Installed
[X] Hyper-V Management Tools RSAT-Hyper-V-Tools Installed
[X] Hyper-V Module for Windows PowerShell Hyper-V-PowerShell Installed |
I don't have operating system that runs inside of VirtualBox that supports Hyper-V. I only have Linux and Windows 7 VMs. Alex |
Alex, I think Eric can make a reproducer CL that runs on a Windows builder instance. We just need to know how a Go test program (run by the builder) can call a local script. Where in the tree should the test program & script live, and what path should exec.Command() use for the script? The test program looks something like:
|
To get Windows is really easy.
There is also always the option to download an evaluation version, for example Windows 10 Enterprise. The evaluation version will be good for half a year. The insider previews also come with a version-specific expiration date, but I believe those are valid a little longer. |
Is this still true? The post is from 2018. How to enable nested virtualization on Google Cloud
I'm not sure if that would be a blocker, since I have no clue whether that also means VM's inside such a machine can run Windows. That would at least be very unhandy, having to run some *nix with a Windows VM inside it with nested virtualization enabled twice just to create some VHD's. But it would be very easy to just run go tests on Microsoft Azure. The script this program calls can be run with
|
That said any number of disks attached to a regular VM would be sufficient to demonstrate the issues - as long as the machine uses GPT any and all partitions will have partition access paths and can be configured to use any drive letters or not, access paths and links and junctions. The repro steps include this line $part = $vhd | Get-Disk | New-Partition -UseMaximumSize -AssignDriveLetter:$false But all that is needed is to initialize the $part = Get-Disk -Number 0 | Get-Partition | where Type -eq Basic | sort Size | select -First 1
$part = Get-Partition -DiskNumber 0 -PartitionNumber 3
$part = Get-Partition -DriveLetter C Then these commands allow reproducing the issue against any partition on the machine: # list
$part.AccessPaths
# directly configured access path
$part | Add-PartitionAccessPath -AccessPath foofullpath
$part | Remove-PartitionAccessPath -AccessPath foofullpath
# directory junction
mklink /j foo ($part | Get-Volume).Path
rmdir foo
# hardlink
mkdir /d foo ($part | Get-Volume).Path
rmdir foo although beware that the issues do not reproduce if the partition already has a drive letter or any other DOS device path with a drive letter. Now to get a partition that is OK to be modified (or several), run: $boot = Get-Partition -DriveLetter C
$size = $part.Size - 128MB
$boot | Resize-Partition -Size $size
$disk = $boot | Get-Disk
for ($i = 0; $i -lt 4; $i++) {
$part = $disk | New-Partition -Size 8MB -AssignDriveLetter:$false
$part | Format-Volume -Label "TestPart$i" -FileSystem NTFS
} for example. I am not sure about minimum sizes and hence how much space is needed. But with these examples you can make it any way you like, on any disk you like. At least if the disk is directly attached - external disks over USB and SD cards and the like are weird, might not be formatted with GPT or look to Windows like that, even if they are and might not be able to have more than one partition. |
Eric & Alex, let's focus on creating a VHDX on a Go builder for Windows, as any Go project member could run a builder. Creating a CL with the repro script should be easy, we just need the info I listed above. |
Normally I create temp directory, and put whatever I need there. And delete after test is finished.
I don't have Microsoft Account. I don't want to create an account just to run this repo. If nothing else, I can create Windows VM on Google Cloud or something. But that would take me long time, because I need to install all appropriate tools. And I don't install Windows every day, so, I expect, it will take me awhile to figure out.
I have no idea.
I don't know what "machine uses GPT" means. If you give me steps to repro, I will try them. Thank you. Alex |
See also Hard Drives and Partitions | Microsoft Docs. On Windows it is just massively much easier to do things like resizing partitions and add a few than on *nix. All the steps you need have been described here and here. You can also use pointy clicky Disk Management or command line tools that won't have you read massive amounts of man pages and then still have you try and hopefullly not die and hack the kernel: diskpart. |
I have exactly the same issue and this problem is anoying for a better automation on Windows. A Symlink can be done on a file or folder and point to another filer or folder or even Junction. But it's virtual. The function Exemple :
As mentioned above the volume ID is probably related to GPT format, but the overall idea should be the same with MBR. For now as workaround I added a letter to my volume to let docker service start but it also mess up the automations because in the case of docker the "configured root path" (in deamon.json) is different than the output in |
Hello, Any chance to move forward on this problem ? As exemples I have :
The solutions seems around : go/src/path/filepath/path_windows.go Line 61 in e09bbae
and
But the logic in this functions seems kind of blur to me. |
Or Docker should stop using EvalSymlinks. And crappy workarounds like isUNC. And support Windows properly in general. https://github.com/search?q=repo%3Adocker%2Fcli+evalsymlinks&type=code This PR has been open for ages for one docker/cli#2649 |
Change https://go.dev/cl/516695 mentions this issue: |
Change https://go.dev/cl/536655 mentions this issue: |
Change https://go.dev/cl/565136 mentions this issue: |
What version of Go are you using (
go version
)?go 1.13
Does this issue reproduce with the latest release?
Not tested
What operating system and processor architecture are you using (
go env
)?set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
go env
OutputWhat did you do?
Create a symlink from volume id
mklink /D \my\path \?\Volume{1b3b1146-4076-11e1-84aa-806e6f6e6963}\
Running
filepath.EvalSymlinks
against a symlink (\my\path) which is created from a volumeid returns the following error:What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: