windows: Use GetFinalPathNameByHandle for ResolveSymbolicLink#5411
windows: Use GetFinalPathNameByHandle for ResolveSymbolicLink#5411estesp merged 1 commit intocontainerd:masterfrom
Conversation
cf2152d to
b6f688d
Compare
d506042 to
50b2d37
Compare
|
LGTM! |
be4dd63 to
4fc8e28
Compare
|
I've fixed up some logic, expanded the comments to explain better why we are doing it this way, and added some unit tests. However, I'm having trouble getting some of the more interesting tests to work currently, as they require creating/mounting VHDs. I initially used the Hyper-V PowerShell cmdlets, but those are not present on the CI machines, and my attempt to install them was not successful. I'm looking into if there's another way I can do the VHD setup that is needed. Otherwise I'll probably need to take out some of the test cases, or find a way to put them behind a feature flag. The implementation of |
62ade5c to
001659e
Compare
|
Okay! Finally got the tests to run properly. Everything passes now except for The only issue I see is that to properly implement VHD formatting I had to detect the Windows OS version we are running on, which brings in the I could remove the version detection given the CI only runs on WS2019, but that's not ideal since someone might need to run it locally, and we don't want to prevent the CI machines from being upgraded. I could also move the |
001659e to
ee116ec
Compare
|
Build succeeded.
|
|
Thanks for your effort, @kevpar . cc @estesp |
|
/test pull-containerd-node-e2e |
|
Build succeeded.
|
|
@estesp looks like this is properly signed off. Could you please help merge? |
|
@kevpar Is there a plan to get this cherry-picked into 1.4.x as well ? Or the only path will be into 1.5.1 ? |
@ibabou yes, I have a PR out to backport to |
That's awesome, thanks Kevin! |
|
@kevpar I don't see the change in release/1.5. Is there a pending thing related to it ? Seems both 1.5.1 and 1.5.2 got published without it ? |
Yeah, I noticed too that the PR of the cherry-pick did seem to not have gone in release/1.5 :). Thanks a lot Kevin! |
`filepath.EvalSymlinks` does not work well on Windows, and can enter infinite loops in certain situations and error out. Use Win32 API GetFinalPathNameByHandle to handle path resolution. Implementation based off on: containerd/containerd#5411 Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
`filepath.EvalSymlinks` does not work well on Windows, and can enter infinite loops in certain situations and error out. Use Win32 API GetFinalPathNameByHandle to handle path resolution. Implementation based off on: containerd/containerd#5411 Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
`filepath.EvalSymlinks` does not work well on Windows, and can enter infinite loops in certain situations and error out. Use Win32 API GetFinalPathNameByHandle to handle path resolution. Implementation based off on: containerd/containerd#5411 Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
`filepath.EvalSymlinks` does not work well on Windows, and can enter infinite loops in certain situations and error out. Use Win32 API GetFinalPathNameByHandle to handle path resolution. Implementation based off on: containerd/containerd#5411 Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
`filepath.EvalSymlinks` does not work well on Windows, and can enter infinite loops in certain situations and error out. Use Win32 API GetFinalPathNameByHandle to handle path resolution. Implementation based off on: containerd/containerd#5411 Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
`filepath.EvalSymlinks` does not work well on Windows, and can enter infinite loops in certain situations and error out. Use Win32 API GetFinalPathNameByHandle to handle path resolution. Implementation based off on: containerd/containerd#5411 Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
`filepath.EvalSymlinks` does not work well on Windows, and can enter infinite loops in certain situations and error out. Use Win32 API GetFinalPathNameByHandle to handle path resolution. Implementation based off on: containerd/containerd#5411 Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
`filepath.EvalSymlinks` does not work well on Windows, and can enter infinite loops in certain situations and error out. Use Win32 API GetFinalPathNameByHandle to handle path resolution. Implementation based off on: containerd/containerd#5411 Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
`filepath.EvalSymlinks` does not work well on Windows, and can enter infinite loops in certain situations and error out. Use Win32 API GetFinalPathNameByHandle to handle path resolution. Implementation based off on: containerd/containerd#5411 Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
`filepath.EvalSymlinks` does not work well on Windows, and can enter infinite loops in certain situations and error out. Use Win32 API GetFinalPathNameByHandle to handle path resolution. Implementation based off on: containerd/containerd#5411 Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
* Add `fs.ResolvePath` to resolve symbolic links `filepath.EvalSymlinks` does not work well on Windows, and can enter infinite loops in certain situations and error out. Use Win32 API GetFinalPathNameByHandle to handle path resolution. Implementation based off on: containerd/containerd#5411 Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com> * PR: types, documentation Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com> * remove unneded constant groups Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com> * Attempt normalized path first Update logic to try querying for normalized path initially, then use opened path if access is denied. Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com> --------- Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
This change splits the definition of pkg/cri/os.ResolveSymbolicLink by
platform (windows/!windows), and switches to an alternate implementation
for Windows. This aims to fix the issue described in #5405.
The previous implementation which just called filepath.EvalSymlinks has
historically had issues on Windows. One of these issues we were able to
fix in Go, but EvalSymlinks's behavior is not well specified on
Windows, and there could easily be more issues in the future, so it
seems prudent to move to a separate implementation for Windows.
The new implementation uses the Windows GetFinalPathNameByHandle API,
which takes a handle to an open file or directory and some flags, and
returns the "real" name for the object. See comments in the code for
details on the implementation.
I have tested this change with a variety of mounts and everything seems
to work as expected. Functions that make incorrect assumptions on what a
Windows path can look like may have some trouble with the \\?\ path
syntax. For instance EvalSymlinks fails when given a \\?\UNC\ path. For
this reason, the resolvePath implementation modifies the returned path
to translate to the more common form (\\?\UNC\server\share ->
\\server\share).
Signed-off-by: Kevin Parsons kevpar@microsoft.com