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

support mount options in azure file #54674

Merged
merged 2 commits into from
Nov 17, 2017

Conversation

andyzhangx
Copy link
Member

@andyzhangx andyzhangx commented Oct 27, 2017

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, #54610

Special 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 in mountOptions field(see below), then azure file should use user specified mount options.

---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: azurefile
provisioner: kubernetes.io/azure-file
mountOptions:
  - dir_mode=0377
  - file_mode=0350
  - vers=2.1
  - uid=1000
  - gid=1000
parameters:
  skuName: Standard_LRS
  location: westus2

Release note:

Support mount options in azure file

/sig azure

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/azure size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 27, 2017
@andyzhangx
Copy link
Member Author

/test pull-kubernetes-unit

@andyzhangx
Copy link
Member Author

/test pull-kubernetes-e2e-gce

@@ -48,6 +48,10 @@ var _ volume.PersistentVolumePlugin = &azureFilePlugin{}

const (
azureFilePluginName = "kubernetes.io/azure-file"
fileModeName = "file_mode"
dirModeName = "dir_mode"
defaultFileMode = "700"
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@@ -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
Copy link
Member

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)},
},
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@@ -222,11 +226,12 @@ func (b *azureFileMounter) SetUpAt(dir string, fsGroup *int64) error {
} else {
os.MkdirAll(dir, 0700)
Copy link
Member

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.

Copy link
Member Author

@andyzhangx andyzhangx Oct 27, 2017

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.

@gnufied
Copy link
Member

gnufied commented Oct 27, 2017

mostly lgtm to me. Please fix the gofmt issue..

Copy link
Member

@feiskyer feiskyer left a comment

Choose a reason for hiding this comment

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

/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 28, 2017
@andyzhangx
Copy link
Member Author

/test pull-kubernetes-bazel-test

@andyzhangx
Copy link
Member Author

@rootfs could you help review, thx

@andyzhangx
Copy link
Member Author

/test pull-kubernetes-bazel-test

@andyzhangx
Copy link
Member Author

/test pull-kubernetes-e2e-gce

@andyzhangx
Copy link
Member Author

andyzhangx commented Nov 15, 2017

@rootfs @brendanburns


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"
Copy link
Contributor

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

Copy link
Member Author

@andyzhangx andyzhangx Nov 16, 2017

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

const (
fileModeName = "file_mode"
dirModeName = "dir_mode"
defaultFileMode = "700"
Copy link
Contributor

Choose a reason for hiding this comment

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

0700

Copy link
Member Author

Choose a reason for hiding this comment

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

thx for check

fileModeName = "file_mode"
dirModeName = "dir_mode"
defaultFileMode = "700"
defaultDirMode = "700"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: 0700

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

contain

Copy link
Member Author

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)}
Copy link
Contributor

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).

Copy link
Member Author

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

@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 16, 2017
use JoinMountOptions func

add a new test case

move const vars

fix fmt issue
@andyzhangx
Copy link
Member Author

/assign @rootfs

@rootfs
Copy link
Contributor

rootfs commented Nov 17, 2017

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 17, 2017
@k8s-github-robot
Copy link

[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 /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 17, 2017
@k8s-github-robot
Copy link

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.

@k8s-github-robot k8s-github-robot merged commit e4a6d42 into kubernetes:master Nov 17, 2017
k8s-github-robot pushed a commit that referenced this pull request Nov 28, 2017
…4674-upstream-release-1.8

Automatic merge from submit-queue.

Automated cherry pick of #54674

Cherry pick of #54674 on release-1.8.

#54674: support mount options in azure file
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. 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. 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.

azure_file volumes should allow setting of dir_mode and file_mode
10 participants