Skip to content

Bug fix for mount path handling#6651

Merged
estesp merged 1 commit intocontainerd:mainfrom
ambarve:mount_path_fix
Mar 23, 2022
Merged

Bug fix for mount path handling#6651
estesp merged 1 commit intocontainerd:mainfrom
ambarve:mount_path_fix

Conversation

@ambarve
Copy link
Copy Markdown
Contributor

@ambarve ambarve commented Mar 9, 2022

Currently when handling 'container_path' elements in container mounts we simply call
filepath.Clean on those paths. However, filepath.Clean adds an extra '.' if the path is a
simple drive letter ('E:' or 'Z:' etc.). Similarly, a drive path like Z:\ is also kept as
it is with an ending ''. Either of these type of paths cause failures (with incorrect
parameter error) when creating containers via hcsshim. This commit correctly removes the
'.' or '' at the end of the paths.

Signed-off-by: Amit Barve [email protected]

@k8s-ci-robot
Copy link
Copy Markdown

Hi @ambarve. Thanks for your PR.

I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ambarve
Copy link
Copy Markdown
Contributor Author

ambarve commented Mar 9, 2022

@kevpar Please take a look.

@ambarve
Copy link
Copy Markdown
Contributor Author

ambarve commented Mar 9, 2022

Fixes #6589

Comment thread pkg/cri/opts/spec_windows.go Outdated
@kzys
Copy link
Copy Markdown
Member

kzys commented Mar 9, 2022

Is C:\ different from C: universally in Windows? Should we wrap filepath.Clean to be more Windows-friendly?

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Mar 9, 2022

Build succeeded.

  • containerd-build-arm64 : RETRY_LIMIT in 3m 39s (non-voting)
  • containerd-test-arm64 : RETRY_LIMIT in 6m 30s (non-voting)
  • containerd-integration-test-arm64 : RETRY_LIMIT in 28m 38s (non-voting)

@kevpar
Copy link
Copy Markdown
Member

kevpar commented Mar 9, 2022

Is C:\ different from C: universally in Windows? I wonder whether we should wrap filepath.Clean or not.

Yes, these are different. C:\ represents the "root directory" of the C drive, whereas C: can have two different meanings based on context:

  • It could mean we are talking about the C drive itself. This is the desired meaning here, where we are mapping a directory into the container as a drive that doesn't currently exist.
  • To indicate the working directory on the C drive. To understand this, we need to know that for various weird historical reasons, Windows has (at least in some places) support for actually tracking a working directory per drive. In this case the drive letter and colon can be used to refer to a path relative to that drive's working directory. So for instance D:foo\bar.txt refers to foo\bar.txt relative to the D drive's working directory.
    Presumably for compatibility, Go seems to have carried over this behavior into filepath.Clean. In this case it is converting D: into D:., which is correct when you consider how this form is used for a relative path.

For our case here, we don't care about relative paths for mounts, and we want to treat the drive letter as a special case, because it allows us to mount a directory as a new drive in the container.

Maybe an argument could be made that we should also support D:\ to mount to a new drive. I'm not sure if that's a good idea or not.

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Mar 9, 2022

Build succeeded.

  • containerd-build-arm64 : RETRY_LIMIT in 3m 46s (non-voting)
  • containerd-test-arm64 : RETRY_LIMIT in 5m 46s (non-voting)
  • containerd-integration-test-arm64 : RETRY_LIMIT in 26m 02s (non-voting)

Copy link
Copy Markdown
Member

@kzys kzys left a comment

Choose a reason for hiding this comment

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

The change looks good. Can you squash the commits into one?

@jterry75
Copy link
Copy Markdown
Contributor

jterry75 commented Mar 9, 2022

I'm confused. I'm sure you tested this but I thought a Windows mount had to be to a nonexistent folder? I didn't know you could do:

C:\Path\On\Host -> C: (in the container)

Does it just place the files from Host alongside whatever is already present in C:? How are conflicts resolved?

@ambarve
Copy link
Copy Markdown
Contributor Author

ambarve commented Mar 9, 2022

@jterry75 Good point. Providing C: as the destination path fails (with invalid data error) because that's not supported (not sure if there is even a way to properly support it) but we don't have a check for that here. I will add that check.
AFAIK containers don't start with other drives and so this question won't arise for other drives.

@ambarve ambarve force-pushed the mount_path_fix branch 2 times, most recently from cd3aca0 to f70fcbd Compare March 9, 2022 19:48
@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Mar 9, 2022

Build succeeded.

  • containerd-build-arm64 : RETRY_LIMIT in 3m 44s (non-voting)
  • containerd-test-arm64 : RETRY_LIMIT in 5m 47s (non-voting)
  • containerd-integration-test-arm64 : RETRY_LIMIT in 25m 46s (non-voting)

Comment thread pkg/cri/opts/spec_windows.go Outdated
@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Mar 16, 2022

Build succeeded.

Comment thread pkg/cri/opts/spec_test.go Outdated
Comment thread pkg/cri/opts/spec_test.go Outdated
Comment thread pkg/cri/opts/spec_windows.go
@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Mar 18, 2022

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Mar 18, 2022

Build succeeded.

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Mar 18, 2022

Build succeeded.

Copy link
Copy Markdown
Contributor

@jterry75 jterry75 left a comment

Choose a reason for hiding this comment

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

LGTM. The linter looks like its static checks on unchanged files.

@kzys
Copy link
Copy Markdown
Member

kzys commented Mar 18, 2022

Rebasing against main should fix the linter issue.

@ambarve
Copy link
Copy Markdown
Contributor Author

ambarve commented Mar 18, 2022

@kzys & @jterry75 actually I moved the entire dst path check out of the named pipe if condition since those checks can & should happen regardless of whether src is a pipe or not. I also rebased on master. PTAL and feel free to merge it if it looks good.

@jterry75
Copy link
Copy Markdown
Contributor

Looks like the pipe mount test is what failed. Can you take a look?

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Mar 18, 2022

Build succeeded.

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Mar 19, 2022

Build succeeded.

Currently when handling 'container_path' elements in container mounts we simply call
filepath.Clean on those paths. However, filepath.Clean adds an extra '.' if the path is a
simple drive letter ('E:' or 'Z:' etc.). These type of paths cause failures (with incorrect
parameter error) when creating containers via hcsshim. This commit checks for such paths
and doesn't call filepath.Clean on them.
It also adds a new check to error out if the destination path is a C drive and moves the
dst path checks out of the named pipe condition.

Signed-off-by: Amit Barve <[email protected]>
@ambarve
Copy link
Copy Markdown
Contributor Author

ambarve commented Mar 21, 2022

@kevpar, @jterry75, @kzys looks like all the tests are passing now (I fixed the issue). Feel free to merge this if it looks good.

Copy link
Copy Markdown
Member

@kzys kzys left a comment

Choose a reason for hiding this comment

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

LGTM!

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Mar 21, 2022

Build succeeded.

Copy link
Copy Markdown
Contributor

@jterry75 jterry75 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

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

LGTM

@estesp estesp merged commit b06938c into containerd:main Mar 23, 2022
@estesp estesp added cherry-picked/1.6.x PR commits are cherry-picked into release/1.6 branch and removed needs-ok-to-test labels May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked/1.6.x PR commits are cherry-picked into release/1.6 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants