Skip to content
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

os.Stat() return error for socket file in 20H2 Windows image & does not work for symlink points to a dir (in all Windows version) #97

Closed
jingxu97 opened this issue Mar 3, 2021 · 8 comments
Assignees
Labels
App Compatibility Cross-platform compatibility assurance

Comments

@jingxu97
Copy link

jingxu97 commented Mar 3, 2021

While testing the new 20H2 windows image, we discovered that golang function os.Stat() always return error when checking a socket file. See the error message

os.Stat error CreateFile C:\var\lib\kubelet\plugins_registry\pd.csi.storage.gke.io-reg.sock: The file cannot be accessed by the system
@jingxu97
Copy link
Author

jingxu97 commented Mar 4, 2021

Another discovery is os.Stat() does not work (no matter which version of Windows) on symlink that points to a dir.
The error is "Access is denied"

@jingxu97 jingxu97 changed the title os.Stat() return error for socket file in 20H2 Windows image os.Stat() return error for socket file in 20H2 Windows image and does not work for symlink points to a dir (in all Windows version) Mar 4, 2021
@neolit123
Copy link

looks like there are a number of issues related to the stdlib os.Stat:
golang/go#39183
golang/go#34900

if Lstat works you can continue using that but it would not follow links.

alternatively, you can write your own local wrapper that imports and uses e.g. CreateFile() (or use the imported one in https://github.com/golang/sys/blob/94ec62e081691fed0145b707594111cee9cb360a/windows/syscall_windows.go)

the CreateFile() link following semantics are here:
https://docs.microsoft.com/en-us/windows/win32/fileio/symbolic-link-effects-on-file-systems-functions#createfile-and-createfiletransacted

@marosset
Copy link
Member

@immuzz @vrapolinario Any updates here?
It seems like this is a new regression and Windows Server 2019 and/or 1909 are not impacted.

@vrapolinario vrapolinario self-assigned this Mar 12, 2021
@vrapolinario vrapolinario added App Compatibility Cross-platform compatibility assurance and removed triage New and needs attention labels Mar 12, 2021
@vrapolinario
Copy link
Contributor

Starting internal investigation on this.

@jingxu97 jingxu97 changed the title os.Stat() return error for socket file in 20H2 Windows image and does not work for symlink points to a dir (in all Windows version) os.Stat() return error for socket file in 20H2 Windows image & does not work for symlink points to a dir (in all Windows version) Mar 29, 2021
@jingxu97
Copy link
Author

jingxu97 commented Apr 14, 2021

os.Stat() seems ok for symlink on ltsc 2019 I just tested. (will confirm 20H2 later).

But for Windows container, if it checks symlink point to a different disk partition, it will not work. I put details in this doc https://docs.google.com/document/d/1hMn2LwFjXDbIzn3ZK_xiw4eNYnAajTIIyRXyQKaKa20/

@vrapolinario
Copy link
Contributor

Quick update that we're still investigating this issue internally.

@vrapolinario
Copy link
Contributor

For internal MS folks: Bug filled: Bug 32905775

@vrapolinario
Copy link
Contributor

Sorry for the delay on this. Here's the result from the internal investigation:

The os.Stat() implementation never should have worked. Windows had a short-term regression during which the os.Stat() implementation worked OK with socket files on some versions (Server 2019), accidentally. Current versions (20H2 and forward) of Windows function correctly. We strongly recommend that os.Stat() should handle the error case STATUS_IO_REPARSE_TAG_NOT_HANDLED and respond by opening the file with the FILE_OPEN_REPARSE_POINT flag specified.

            Which is approximately what this Go patch implements: os: fallback to open symlinks (Ib919e5ce) · Gerrit Code Review (googlesource.com): https://go-review.googlesource.com/c/go/+/265037
            That patch retries with FILE_OPEN_REPARSE_POINT in case of any error aside from ERROR_CANT_ACCESS_FILE – which is overly inclusive, but should solve the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
App Compatibility Cross-platform compatibility assurance
Projects
None yet
Development

No branches or pull requests

4 participants