-
Notifications
You must be signed in to change notification settings - Fork 39.7k
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
support mount options in azure file #54674
support mount options in azure file #54674
Conversation
/test pull-kubernetes-unit |
/test pull-kubernetes-e2e-gce |
pkg/volume/azure_file/azure_file.go
Outdated
@@ -48,6 +48,10 @@ var _ volume.PersistentVolumePlugin = &azureFilePlugin{} | |||
|
|||
const ( | |||
azureFilePluginName = "kubernetes.io/azure-file" | |||
fileModeName = "file_mode" | |||
dirModeName = "dir_mode" | |||
defaultFileMode = "700" |
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.
defaultFileMode
is used only in tests. Why declaring here?
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.
Also I suggest moving these const vars to azure_util.go
.
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
pkg/volume/azure_file/azure_util.go
Outdated
@@ -84,3 +85,29 @@ func (s *azureSvc) SetAzureCredentials(host volume.VolumeHost, nameSpace, accoun | |||
} | |||
return secretName, err | |||
} | |||
|
|||
// check whether mountOptions contains 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.
nit: appendDefaultMountOptions checks
{ | ||
options: []string{"file_mode=0777"}, | ||
expected: []string{"file_mode=0777", fmt.Sprintf("%s=%s", dirModeName, defaultDirMode)}, | ||
}, |
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.
nit: add another case of setting both
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
3836db6
to
557822b
Compare
@@ -222,11 +226,12 @@ func (b *azureFileMounter) SetUpAt(dir string, fsGroup *int64) error { | |||
} else { | |||
os.MkdirAll(dir, 0700) |
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.
You should use the dir_mode
value if defined, otherwise defaultFileMode when the root folder is created.
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.
actually here dir
is the k8s path in the agent node, e.g. /var/lib/kubelet/plugins/kubernetes.io/azure-disk/mounts/b1246717734
, not the container mount path, k8s would then use volume mapping between dir
and container mount path. So dir_mode
is different here, we should not set os.MkdirAll(dir, 0700)
as dir_mode
in mountOptions
.
mostly lgtm to me. Please fix the gofmt issue.. |
557822b
to
be97c91
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.
/lgtm
/test pull-kubernetes-bazel-test |
@rootfs could you help review, thx |
/test pull-kubernetes-bazel-test |
/test pull-kubernetes-e2e-gce |
pkg/volume/azure_file/azure_util.go
Outdated
|
||
v1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/api/errors" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/kubernetes/pkg/volume" | ||
) | ||
|
||
const ( | ||
fileModeName = "file_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.
a bit paranoid but file_mode=
is safer to me (and dir_mode=
) too
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.
fileMode is better, underscore is not good in go var naming convention
pkg/volume/azure_file/azure_util.go
Outdated
const ( | ||
fileModeName = "file_mode" | ||
dirModeName = "dir_mode" | ||
defaultFileMode = "700" |
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.
0700
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.
thx for check
pkg/volume/azure_file/azure_util.go
Outdated
fileModeName = "file_mode" | ||
dirModeName = "dir_mode" | ||
defaultFileMode = "700" | ||
defaultDirMode = "700" |
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.
nit: 0700
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
pkg/volume/azure_file/azure_util.go
Outdated
@@ -84,3 +92,29 @@ func (s *azureSvc) SetAzureCredentials(host volume.VolumeHost, nameSpace, accoun | |||
} | |||
return secretName, err | |||
} | |||
|
|||
// check whether mountOptions contains 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.
contain
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
@@ -222,11 +222,12 @@ func (b *azureFileMounter) SetUpAt(dir string, fsGroup *int64) error { | |||
} else { | |||
os.MkdirAll(dir, 0700) | |||
// parameters suggested by https://azure.microsoft.com/en-us/documentation/articles/storage-how-to-use-files-linux/ | |||
options := []string{fmt.Sprintf("vers=3.0,username=%s,password=%s,dir_mode=0700,file_mode=0700", accountName, accountKey)} |
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.
allow vers override too?this example uses vers=2.1 (not good idea though).
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 have added vers
as a mount option
be97c91
to
5f20ffb
Compare
use JoinMountOptions func add a new test case move const vars fix fmt issue
5f20ffb
to
e316bbc
Compare
/assign @rootfs |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andyzhangx, feiskyer, rootfs Associated issue: 37005 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 |
Automatic merge from submit-queue (batch tested with PRs 55254, 55525, 50108, 54674, 55263). If you want to cherry-pick this change to another branch, please follow the instructions here. |
What this PR does / why we need it:
support mount options in azure file
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes #37005, #54610Special notes for your reviewer:
@rootfs @karataliu @feiskyer
By default, the dir_mode and file_mode would be 0700, vers would be 3.0, while if user specify
dir_mode
,file_mode
,vers
in storage class inmountOptions
field(see below), then azure file should use user specified mount options.Release note:
/sig azure