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 permissions when using fsGroup #37009

Merged

Conversation

sjenning
Copy link
Contributor

@sjenning sjenning commented Nov 17, 2016

Currently, when an fsGroup is specified, the permissions of the defaultMode are not respected and all files created by the atomic writer have mode 777. This is because in SetVolumeOwnership() the filepath.Walk includes the symlinks created by the atomic writer. The symlinks have mode 777 when read from info.Mode(). However, when they are chmod'ed later, the chmod applies to the file the symlink points to, not the symlink itself, resulting in the wrong mode for the underlying file.

This PR skips chmod/chown for symlinks in the walk since those operations are carried out on the underlying file which will be included elsewhere in the walk.

xref https://bugzilla.redhat.com/show_bug.cgi?id=1384458

@derekwaynecarr @pmorie


This change is Reviewable

@k8s-github-robot k8s-github-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. release-note-label-needed labels Nov 17, 2016
@k8s-ci-robot
Copy link
Contributor

Jenkins GCI GCE e2e failed for commit a349fa7. Full PR test history.

The magic incantation to run this job again is @k8s-bot gci gce e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@sjenning
Copy link
Contributor Author

@k8s-bot gci gce e2e test this

@pmorie pmorie added sig/storage Categorizes an issue or PR as relevant to SIG Storage. release-note-none Denotes a PR that doesn't merit a release note. labels Nov 17, 2016
@pmorie
Copy link
Member

pmorie commented Nov 17, 2016

I think this fix is good, but we need to encode some context about why it is okay to skip symlinks. Remember, this code might also run against any number of block device-provided volumes, so we need a broad understanding of why the code is the way it is to be communicated with this change as comments.

@derekwaynecarr
Copy link
Member

test case?

@pmorie
Copy link
Member

pmorie commented Nov 17, 2016

Yes, this needs E2E coverage added for configmap/secret/downward API

@pmorie
Copy link
Member

pmorie commented Nov 17, 2016

cc @kubernetes/sig-storage

@derekwaynecarr
Copy link
Member

@saad-ali -- i would like this to be a cherry-pick for 1.5 once a test case is added.

@derekwaynecarr derekwaynecarr added this to the v1.5 milestone Nov 17, 2016
@derekwaynecarr derekwaynecarr added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Nov 17, 2016
@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 17, 2016
@sjenning
Copy link
Contributor Author

@derekwaynecarr @pmorie added comments and e2e tests

@saad-ali
Copy link
Member

@saad-ali -- i would like this to be a cherry-pick for 1.5 once a test case is added.

The issue it is fixing, was it introduced in 1.5? How bad is the issue it is fixing, can we ship 1.5 with it? How risky is the fix to the rest of the 1.5 release?

@sjenning
Copy link
Contributor Author

@saad-ali it isn't risky as chowning/chmoding symlinks was only corrupting the mode of underlying files before this PR. I'm not sure when it was introduced exactly but it predates the 1.5 cycle.

@pmorie
Copy link
Member

pmorie commented Nov 18, 2016

This has been an issue since 1.3 afaict

On Friday, November 18, 2016, Seth Jennings notifications@github.com
wrote:

@saad-ali https://github.com/saad-ali it isn't risky as
chowning/chmoding symlinks was only corrupting the mode of underlying files
before this PR. I'm not sure when it was introduced exactly but it predates
the 1.5 cycle.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#37009 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAWXmPU9_qkNI9ylfpzKAo-iRbNRLeOPks5q_dqCgaJpZM4K1mlg
.

@saad-ali
Copy link
Member

@saad-ali it isn't risky as chowning/chmoding symlinks was only corrupting the mode of underlying files before this PR. I'm not sure when it was introduced exactly but it predates the 1.5 cycle.

Ack. Ok for post-code freeze merge.

As an FYI, last chance for automatic merge to 1.5 branch will Nov 23 10 AM PST. At that point: https://groups.google.com/forum/#!topic/kubernetes-dev/n-vqlX-HHSM

@derekwaynecarr
Copy link
Member

@pmorie bump

Copy link
Member

@pmorie pmorie left a comment

Choose a reason for hiding this comment

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

Looking closer, but I thought we were going to add tests for downward API volume as well.

@@ -51,6 +51,17 @@ func SetVolumeOwnership(mounter Mounter, fsGroup *int64) error {
return err
}

// chown and chmod pass through to the underlying file for symlinks.
Copy link
Member

Choose a reason for hiding this comment

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

underlying

Copy link
Member

Choose a reason for hiding this comment

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

weird rendering error, disregard

@@ -41,6 +41,11 @@ var _ = framework.KubeDescribe("ConfigMap", func() {
doConfigMapE2EWithoutMappings(f, 0, 0, &defaultMode)
})

It("should be consumable from pods in volume with defaultMode and fsGroup set [Conformance]", func() {
Copy link
Member

Choose a reason for hiding this comment

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

how about a test for non-root, default mode, and fsgroup?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

after thinking about it, this should probably be a non-root only test

doSecretE2EWithoutMapping(f, &defaultMode, "secret-test-"+string(uuid.NewUUID()), nil)
})

It("should be consumable from pods in volume with defaultMode and fsGroup set [Conformance]", func() {
Copy link
Member

Choose a reason for hiding this comment

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

same comment for secrets -- i'd like to see nonroot, fsgroup, and default mode in a test case.

@pmorie pmorie added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 7, 2016
@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-ci-robot
Copy link
Contributor

Jenkins unit/integration failed for commit 51ae5a3. Full PR test history.

The magic incantation to run this job again is @k8s-bot unit test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 38294, 37009, 36778, 38130, 37835)

k8s-github-robot pushed a commit that referenced this pull request Dec 7, 2016
Automatic merge from submit-queue (batch tested with PRs 38294, 37009, 36778, 38130, 37835)

fix permissions when using fsGroup

Currently, when an fsGroup is specified, the permissions of the defaultMode are not respected and all files created by the atomic writer have mode 777.  This is because in `SetVolumeOwnership()` the `filepath.Walk` includes the symlinks created by the atomic writer.  The symlinks have mode 777 when read from `info.Mode()`.  However, when the are chmod'ed later, the chmod applies to the file the symlink points to, not the symlink itself, resulting in the wrong mode for the underlying file.

This PR skips chmod/chown for symlinks in the walk since those operations are carried out on the underlying file which will be included elsewhere in the walk.

xref https://bugzilla.redhat.com/show_bug.cgi?id=1384458

@derekwaynecarr @pmorie
@k8s-github-robot k8s-github-robot merged commit 0f2c6fc into kubernetes:master Dec 7, 2016
saad-ali added a commit to saad-ali/kubernetes that referenced this pull request Dec 7, 2016
@saad-ali saad-ali added the cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. label Dec 8, 2016
k8s-github-robot pushed a commit that referenced this pull request Dec 8, 2016
#38276-#37009-upstream-release-1.5

Automatic merge from submit-queue

Automated cherry pick of #37594 #38276 #37009 upstream release 1.5

Batch cherry pick PRs #37594 #38276 #37009 from master to release-1.5 branch.

PR #37009 had merge conflicts that needed to be resolved.

CC Original PR Authors: @thockin @mbohlool @mwielgus @sjenning
@k8s-cherrypick-bot
Copy link

Commit found in the "release-1.5" branch appears to be this PR. Removing the "cherrypick-candidate" label. If this is an error find help to get your PR picked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants