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

fix: add trailing backslash to remote path when linking to SMB shares #98

Merged

Conversation

marosset
Copy link
Contributor

@marosset marosset commented Oct 19, 2020

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change

/kind bug

/kind cleanup
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:

This PR addresses an issue where golang fails to properly evaluate symlinks on windows if the link source is remote file share AND there is no trailing backslash (ex: \server\share will not work but \server\share\ will work).

Which issue(s) this PR fixes:

Fixes # kubernetes/kubernetes#94213

Special notes for your reviewer:
This issue is only seen on containerd (not Docker).
Kevin Parsons (@kevpar) investigated this and believes it is becasue docker does not call EvalSymLinks but containerd does.

We'll follow up with a golang bug for this too.

Does this PR introduce a user-facing change?:

Working around some issues with how golang evaluates symlink targets by appending a trailing \ when creating symlinks to SMB shares.

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 19, 2020
@k8s-ci-robot
Copy link
Contributor

Welcome @marosset!

It looks like this is your first PR to kubernetes-csi/csi-proxy 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-csi/csi-proxy has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 19, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @marosset. Thanks for your PR.

I'm waiting for a kubernetes-csi 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.

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.

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Oct 19, 2020
@@ -38,6 +38,13 @@ func (APIImplementor) IsSmbMapped(remotePath string) (bool, error) {
// alpha to merge the paths.
// TODO (for beta release): Merge the link paths - os.Symlink and Powershell link path.
func (APIImplementor) NewSmbLink(remotePath, localPath string) error {

if !strings.HasSuffix(remotePath, "\\") {
Copy link

Choose a reason for hiding this comment

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

Do we expect this code path to ever be used for a file symlink? If so, adding a slash to the end would break it.

Copy link

Choose a reason for hiding this comment

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

We technically only need the slash added if the path is to the share root, also (e.g. \\server\share doesn't work currently, but \\server\share\dir does).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the node I was testing these changes out on only the symlink created against the root share used this codepath.

Here is the state of some symlinks created on that node

azureuser@1876k8s00000000 c:\k>dir "c:\var\lib\kubelet\pods\7819fd8b-cdbd-4292-8554-769ad4af543a\volumes\kubernetes.io~csi\pvc-ee3f6a92-f195-4d9e-841b-6966e6839829"
 Volume in drive C is Windows
 Volume Serial Number is CA78-414E

 Directory of c:\var\lib\kubelet\pods\7819fd8b-cdbd-4292-8554-769ad4af543a\volumes\kubernetes.io~csi\pvc-ee3f6a92-f195-4d9e-841b-6966e6839829

10/19/2020  11:11 PM    <DIR>          .
10/19/2020  11:11 PM    <DIR>          ..
10/19/2020  11:11 PM    <SYMLINKD>     mount [c:\var\lib\kubelet\plugins\kubernetes.io\csi\pv\pvc-ee3f6a92-f195-4d9e-841b-6966e6839829\globalmount]
10/19/2020  11:10 PM               340 vol_data.json
               1 File(s)            340 bytes
               3 Dir(s)  117,465,772,032 bytes free

azureuser@1876k8s00000000 c:\k>dir c:\var\lib\kubelet\plugins\kubernetes.io\csi\pv\pvc-ee3f6a92-f195-4d9e-841b-6966e6839829
 Volume in drive C is Windows
 Volume Serial Number is CA78-414E

 Directory of c:\var\lib\kubelet\plugins\kubernetes.io\csi\pv\pvc-ee3f6a92-f195-4d9e-841b-6966e6839829

10/19/2020  11:11 PM    <DIR>          .
10/19/2020  11:11 PM    <DIR>          ..
10/19/2020  11:11 PM    <SYMLINKD>     globalmount [\\faf486191df3c4f0fad548f.file.core.windows.net\pvc-ee3f6a92-f195-4d9e-841b-6966e6839829\]
10/19/2020  11:10 PM               135 vol_data.json
               1 File(s)            135 bytes
               3 Dir(s)  117,465,772,032 bytes free

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this codepath will only be used for creating links to SMB shares.
Will try and confirm.

Copy link
Contributor

Choose a reason for hiding this comment

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

@andyzhangx

Also want to verify there should be no problem adding trailing backslash in any case. Is there any possibility that remote path is a file?

Copy link
Member

Choose a reason for hiding this comment

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

smb remote path is a folder, this PR lgtm, thanks

@ddebroy
Copy link
Contributor

ddebroy commented Oct 20, 2020

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 20, 2020
@ddebroy ddebroy requested a review from jingxu97 October 20, 2020 05:45
jmpfar pushed a commit to jmpfar/csi-proxy that referenced this pull request Oct 20, 2020
a0f195c Merge pull request kubernetes-csi#106 from msau42/fix-canary
7100c12 Only set staging registry when running canary job
b3c65f9 Merge pull request kubernetes-csi#99 from msau42/add-release-process
e53f3e8 Merge pull request kubernetes-csi#103 from msau42/fix-canary
d129462 Document new method for adding CI jobs are new K8s versions
e73c2ce Use staging registry for canary tests
2c09846 Add cleanup instructions to release-notes generation
60e1cd3 Merge pull request kubernetes-csi#98 from pohly/kubernetes-1-19-fixes
0979c09 prow.sh: fix E2E suite for Kubernetes >= 1.18
3b4a2f1 prow.sh: fix installing Go for Kubernetes 1.19.0
1fbb636 Merge pull request kubernetes-csi#97 from pohly/go-1.15
82d108a switch to Go 1.15
d8a2530 Merge pull request kubernetes-csi#95 from msau42/add-release-process
843bddc Add steps on promoting release images
0345a83 Merge pull request kubernetes-csi#94 from linux-on-ibm-z/bump-timeout
1fdf2d5 cloud build: bump timeout in Prow job
41ec6d1 Merge pull request kubernetes-csi#93 from animeshk08/patch-1
5a54e67 filter-junit: Fix gofmt error
0676fcb Merge pull request kubernetes-csi#92 from animeshk08/patch-1
36ea4ff filter-junit: Fix golint error
f5a4203 Merge pull request kubernetes-csi#91 from cyb70289/arm64
43e50d6 prow.sh: enable building arm64 image
0d5bd84 Merge pull request kubernetes-csi#90 from pohly/k8s-staging-sig-storage
3df86b7 cloud build: k8s-staging-sig-storage
c5fd961 Merge pull request kubernetes-csi#89 from pohly/cloud-build-binfmt
db0c2a7 cloud build: initialize support for running commands in Dockerfile
be902f4 Merge pull request kubernetes-csi#88 from pohly/multiarch-windows-fix
340e082 build.make: optional inclusion of Windows in multiarch images
5231f05 build.make: properly declare push-multiarch
4569f27 build.make: fix push-multiarch ambiguity
17dde9e Merge pull request kubernetes-csi#87 from pohly/cloud-build
bd41690 cloud build: initial set of shared files
9084fec Merge pull request kubernetes-csi#81 from msau42/add-release-process
6f2322e Update patch release notes generation command
0fcc3b1 Merge pull request kubernetes-csi#78 from ggriffiths/fix_csi_snapshotter_rbac_version_set
d8c76fe Support local snapshot RBAC for pull jobs
c1bdf5b Merge pull request kubernetes-csi#80 from msau42/add-release-process
ea1f94a update release tools instructions

git-subtree-dir: release-tools
git-subtree-split: a0f195cc2ddc2a1f07d4d3e46fc08187db358f94
@jingxu97
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 21, 2020
@jingxu97
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jingxu97, marosset

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Oct 21, 2020
@k8s-ci-robot k8s-ci-robot merged commit 4322716 into kubernetes-csi:master Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants