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

Resolve context root on context.Walk when root is symlink #113

Merged
merged 3 commits into from
May 24, 2018

Conversation

darstahl
Copy link
Contributor

@darstahl darstahl commented May 9, 2018

When the root of a context is a symlink, Walk does not walk the contents of the directory as expected due to the implementation in Golang. This expands the root of a context to the target of the link prior to the walk in order to correctly walk the contents of the context.

Readlink was forked on Windows as there is a bug in Golang that prevents Volume GUID paths of the form \??\Volume from being a valid target of a link. This type of path is necessary for mounted VHDs of Windows container filesystems.

Signed-off-by: Darren Stahl darst@microsoft.com

Signed-off-by: Darren Stahl <darst@microsoft.com>
Signed-off-by: Darren Stahl <darst@microsoft.com>
}
}
return c.pathDriver.Walk(root, func(p string, fi os.FileInfo, err error) error {
contained, err := c.containWithRoot(p, root)
Copy link
Member

Choose a reason for hiding this comment

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

Is the above logic duplicated in container with root?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was, but shouldn't have been. Removed the duplicated logic. containWithRoot now uses the root as given with no modifications.

@dmcgowan
Copy link
Member

dmcgowan commented May 9, 2018

Are you opening up an upstream change to fix the ReadLink issue? sysx is intended to only have temporary changes before they are upstreamed to https://github.com/golang/sys.

Signed-off-by: Darren Stahl <darst@microsoft.com>
@darstahl
Copy link
Contributor Author

darstahl commented May 9, 2018

Yes, the changes will be submitted to Go's Syscall package. The current state of https://github.com/golang/sys syscall package is not up to date with Go master (which contains the patch that broke this), so I'm not sure if this change will land in sys or syscall or both. It is intended to be upstreamed though, and this is just a temporary fork.

@crosbymichael
Copy link
Member

LGTM

1 similar comment
@dmcgowan
Copy link
Member

LGTM

@dmcgowan dmcgowan merged commit d3c2351 into containerd:master May 24, 2018
@kolyshkin
Copy link
Contributor

Yes, the changes will be submitted to Go's Syscall package.

@darstahl can you please point out to those? I did a quick look and can't seem to find any.

@kolyshkin
Copy link
Contributor

Found myself re-reading this today :) If anyone knows if the Windows' readlink bug is fixed in golang, please share the news

@kolyshkin
Copy link
Contributor

Guess what, I found the issue (golang/go#30463) and the fix (https://go-review.googlesource.com/c/go/+/164201, very similar to what we have in here).

Will follow up with the clean patch

kolyshkin added a commit to kolyshkin/continuity that referenced this pull request Feb 27, 2020
This reverts the part of commit 8100e75 (PR containerd#113)
that added the fork of Readlink() for Windows.

At that time the fork was done to work around the bug
in golang's implementation of os.Readlink() for Windows.

The above bug was never reported upstream, but fortunately
it was independently found, reported [1], and fixed [2].
The fix made its way into go-1.13 (there is no mention of
that in release notes, so I checked it in git history).

[1] golang/go#30463
[2] https://go-review.googlesource.com/c/go/+/164201

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
kolyshkin added a commit to kolyshkin/continuity that referenced this pull request Feb 27, 2020
This reverts the part of commit 8100e75 (PR containerd#113)
that added the fork of Readlink() for Windows.

At that time the fork was done to work around the bug
in golang's implementation of os.Readlink() for Windows.

The above bug was never reported upstream, but fortunately
it was independently found, reported [1], and fixed [2].
The fix made its way into go-1.13 (there is no mention of
that in release notes, so I checked it in git history).

[1] golang/go#30463
[2] https://go-review.googlesource.com/c/go/+/164201

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants