-
Notifications
You must be signed in to change notification settings - Fork 40k
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 subPath existence check to not follow symlink #48555
Fix subPath existence check to not follow symlink #48555
Conversation
Hi @redbaron. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with 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. I understand the commands that are listed here. |
lgtm, thanks. given how many issues are popping up with my subpath code I'm debating having it not return an error when MkdirAll/chmod fails, so in those case it would behave like before my patches. Depends on whether we think it's better the pod starts with unexpected/incorrect permissions than not at all. That said I really hope this is the end of the issues since I'd like to think 'symlink subpath + containerized kubelet' is the rarest edge case possible.... |
I think it is doing the right thing, issues will pop up either way, I wouldn't worry about it :) |
/sig sig/node |
How can I assign sig/node and sig/storage labels to draw their attention? |
/ok-to-test @redbaron you can do as following to add labels /sig node |
Volume mounting logic introduced in kubernetes#43775 and kubernetes#45623 checks for subPath existence before attempting to create a directory, should subPath not be present. This breaks if subPath is a dangling symlink, os.Stat returns "do not exist" status, yet `os.MkdirAll` can't create directory as symlink is present at the given path. This patch makes existence check to use os.Lstat which works for normal files/directories as well as doesn't not attempt to follow symlink, therefore it's "do not exist" status is more reliable when making a decision whether to create directory or not. subPath symlinks can be dangling in situations where kubelet is running in a container itself with access to docker socket, such as CoreOS's kubelet-wrapper script
632eef9
to
020ec43
Compare
/lgtm |
/retest |
2 similar comments
/retest |
/retest |
@dchen1107 PTAL for approval |
/test pull-kubernetes-node-e2e |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dchen1107, mtaufen, redbaron Associated issue: 43775 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/test pull-kubernetes-node-e2e |
Automatic merge from submit-queue |
@mtaufen , do I need to submit separate PR to 1.7 branch or it will be cherry-picked automatically? |
Removing label |
I added the cherrypick-candidate label. @wojtek-t PTAL |
@mtaufen - it seems like a reasonable cherrypick candidate. We have some issues with release branch now, but I will make sure this is cherrypicked before cutting 1.7.2 |
Approved - cherrypick in #49089 |
…55-upstream-release-1.7 Automated cherry pick of #48555 upstream release 1.7
Commit found in the "release-1.7" branch appears to be this PR. Removing the "cherrypick-candidate" label. If this is an error find help to get your PR picked. |
What this PR does / why we need it:
Volume mounting logic introduced in #43775 and #45623 checks
for subPath existence before attempting to create a directory,
should subPath not be present.
This breaks if subPath is a dangling symlink, os.Stat returns
"do not exist" status, yet
os.MkdirAll
can't create directoryas symlink is present at the given path.
This patch makes existence check to use os.Lstat which works for
normal files/directories as well as doesn't not attempt to follow
symlink, therefore it's "do not exist" status is more reliable when
making a decision whether to create directory or not.
subPath symlinks can be dangling in situations where kubelet is
running in a container itself with access to docker socket, such
as CoreOS's kubelet-wrapper script
Release note: