-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
set fsGroup by securityContext.fsGroup in azure file #58316
set fsGroup by securityContext.fsGroup in azure file #58316
Conversation
/sig azure |
pkg/volume/azure_file/azure_file.go
Outdated
@@ -225,9 +225,11 @@ func (b *azureFileMounter) SetUpAt(dir string, fsGroup *int64) error { | |||
options := []string{fmt.Sprintf("username=%s,password=%s", accountName, accountKey)} | |||
if b.readOnly { | |||
options = append(options, "ro") | |||
// we don't respect fsGroup value if b.readOnly = true | |||
fsGroup = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can make use of fsGroup here. Some implementations do mount with ro first, so that gid could not be changed later.
Here it should be fine as it is passed via mount option,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to https://github.com/kubernetes/kubernetes/blob/master/pkg/volume/aws_ebs/aws_ebs.go#L379-L381
no fsGroup
value will be set if readOnly = true
if !b.readOnly {
volume.SetVolumeOwnership(b, fsGroup)
}
Anyway I reserved fsGroup value and use groupID
var instead, not change the passing parameter value.
pkg/volume/azure_file/azure_util.go
Outdated
@@ -96,10 +97,11 @@ func (s *azureSvc) SetAzureCredentials(host volume.VolumeHost, nameSpace, accoun | |||
} | |||
|
|||
// check whether mountOptions contain file_mode and dir_mode, if not, append default mode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider updating comment since add gid logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@karataliu PTAL
pkg/volume/azure_file/azure_file.go
Outdated
@@ -225,9 +225,11 @@ func (b *azureFileMounter) SetUpAt(dir string, fsGroup *int64) error { | |||
options := []string{fmt.Sprintf("username=%s,password=%s", accountName, accountKey)} | |||
if b.readOnly { | |||
options = append(options, "ro") | |||
// we don't respect fsGroup value if b.readOnly = true | |||
fsGroup = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to https://github.com/kubernetes/kubernetes/blob/master/pkg/volume/aws_ebs/aws_ebs.go#L379-L381
no fsGroup
value will be set if readOnly = true
if !b.readOnly {
volume.SetVolumeOwnership(b, fsGroup)
}
Anyway I reserved fsGroup value and use groupID
var instead, not change the passing parameter value.
pkg/volume/azure_file/azure_util.go
Outdated
@@ -96,10 +97,11 @@ func (s *azureSvc) SetAzureCredentials(host volume.VolumeHost, nameSpace, accoun | |||
} | |||
|
|||
// check whether mountOptions contain file_mode and dir_mode, if not, append default mode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
6973118
to
e94a988
Compare
/test pull-kubernetes-kubemark-e2e-gce |
/test pull-kubernetes-e2e-kops-aws |
expected: []string{"file_mode=0777", | ||
fmt.Sprintf("%s=%s", dirMode, defaultDirMode), | ||
fmt.Sprintf("%s=%s", vers, defaultVers), | ||
fmt.Sprintf("%s=0", gid)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a test where input string contains 'gid' and fsGroup is set, to verify gid takes precedence over fsGroup?
Others looks good. Please also do squash commits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
/test pull-kubernetes-e2e-kops-aws |
fix comments fix comments fix comments
e94a988
to
c38e758
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@karataliu PTAL
expected: []string{"file_mode=0777", | ||
fmt.Sprintf("%s=%s", dirMode, defaultDirMode), | ||
fmt.Sprintf("%s=%s", vers, defaultVers), | ||
fmt.Sprintf("%s=0", gid)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andyzhangx, karataliu Associated issue: #44085 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 all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
What this PR does / why we need it:
set fsGroup by securityContext.fsGroup in azure file
This PR respects
securityContext.fsGroup
, while if user both setsgid=xxx
in mountOptions in azure storage class andsecurityContext.fsGroup
,gid=xxx
setting in mountOptions will win.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #44085
Special notes for your reviewer:
Release note:
/assign @karataliu
cc @rootfs @avaranovich