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

add PV size grow feature for azure file #57017

Merged
merged 2 commits into from
Feb 5, 2018

Conversation

andyzhangx
Copy link
Member

What this PR does / why we need it:
According to kubernetes/enhancements#284, add size grow feature for azure file

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 #56462

Special notes for your reviewer:
Since azure file is using SMB 3.0 protocal, there is no necessary to resize filesystem on agent side, the agent node will detect the changed size automatically.

Release note:

add size grow feature for azure file

/sig azure
@gnufied @rootfs @brendandburns

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

/assign @gnufied @rootfs

@andyzhangx
Copy link
Member Author

/test pull-kubernetes-unit

@@ -68,3 +68,19 @@ func (az *Cloud) DeleteFileShare(accountName, key, name string) error {
return nil

}

// ResizeFileShare resize a file share
func (az *Cloud) ResizeFileShare(accountName, accountKey, name string, sizeGB int) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

cannot comment on unchanged lines but createFileShare looks buggy to me: in event of SetProperties() failure, the share should be deleted, otherwise a quota-less share is left unaccounted...

Copy link
Member Author

Choose a reason for hiding this comment

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

createFileShare will delete share when hit SetProperties() failure, it's already implemented, see code:
https://github.com/kubernetes/kubernetes/blob/master/pkg/cloudprovider/providers/azure/azure_file.go#L46-L50

@andyzhangx
Copy link
Member Author

@gnufied PTAL

@thockin thockin removed their assignment Dec 15, 2017
@andyzhangx
Copy link
Member Author

@gnufied PTAL, thanks

@andyzhangx andyzhangx changed the title add size grow feature for azure file add PV size grow feature for azure file Jan 2, 2018
Copy link
Member

@gnufied gnufied left a comment

Choose a reason for hiding this comment

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

Mostly looks okay. needs some minor changes

shareName := spec.PersistentVolume.Spec.AzureFile.ShareName
azure, err := getAzureCloudProvider(plugin.host.GetCloudProvider())
if err != nil {
glog.V(2).Infof("failed to get azure provider")
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't caller log the returned error anyways? so - rather than logging the similar error from two places, it may be better to augment the original and return a modified value via fmt.Errorf ?

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch, actually it's not necessary, I have removed those info logs


secretName, secretNamespace, err := getSecretNameAndNamespace(spec, spec.PersistentVolume.Spec.ClaimRef.Namespace)
if err != nil {
glog.V(2).Infof("failed to get secret")
Copy link
Member

Choose a reason for hiding this comment

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

same as before here..

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

util := &azureSvc{}
accountName, accountKey, err := util.GetAzureCredentials(plugin.host, secretNamespace, secretName)
if err != nil {
glog.V(2).Infof("failed to get account key for secret: %s in namespace: %s", secretName, secretNamespace)
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Copy link
Member Author

Choose a reason for hiding this comment

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

removed

return oldSize, err
}

if err := azure.ResizeFileShare(accountName, accountKey, shareName, int(newSize.Value()/1024/1024/1024)); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

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

}

share := fileClient.GetShareReference(name)
share.Properties.Quota = sizeGB
Copy link
Member

Choose a reason for hiding this comment

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

Is it GB or GiB? It appears that you are passing GiB value from other place.

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks for checking, it's GiB, have changed the var name

Copy link
Member Author

@andyzhangx andyzhangx left a comment

Choose a reason for hiding this comment

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

@gnufied thanks for the review. PTAL.
Next I will work on azure disk resize.

}

share := fileClient.GetShareReference(name)
share.Properties.Quota = sizeGB
Copy link
Member Author

Choose a reason for hiding this comment

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

thanks for checking, it's GiB, have changed the var name

shareName := spec.PersistentVolume.Spec.AzureFile.ShareName
azure, err := getAzureCloudProvider(plugin.host.GetCloudProvider())
if err != nil {
glog.V(2).Infof("failed to get azure provider")
Copy link
Member Author

Choose a reason for hiding this comment

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

good catch, actually it's not necessary, I have removed those info logs


secretName, secretNamespace, err := getSecretNameAndNamespace(spec, spec.PersistentVolume.Spec.ClaimRef.Namespace)
if err != nil {
glog.V(2).Infof("failed to get secret")
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

util := &azureSvc{}
accountName, accountKey, err := util.GetAzureCredentials(plugin.host, secretNamespace, secretName)
if err != nil {
glog.V(2).Infof("failed to get account key for secret: %s in namespace: %s", secretName, secretNamespace)
Copy link
Member Author

Choose a reason for hiding this comment

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

removed

return oldSize, err
}

if err := azure.ResizeFileShare(accountName, accountKey, shareName, int(newSize.Value()/1024/1024/1024)); err != nil {
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

@andyzhangx andyzhangx force-pushed the azurefile-growsize branch 3 times, most recently from 78ecdbf to fe6a549 Compare January 12, 2018 08:31
@andyzhangx
Copy link
Member Author

@karataliu @feiskyer PTAL, thx

if err != nil {
return oldSize, err
}

Copy link
Member

Choose a reason for hiding this comment

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

Add a check of whether newSize is greater than oldSize?

Copy link
Member

@gnufied gnufied Jan 22, 2018

Choose a reason for hiding this comment

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

not sure what @feiskyer meant - but this function should be idempotent and if existing size already satisfies requested new size, no API call should be made. I forgot to mention that.

If you notice corresponding functions in GCE/AWS etc they are all idempotent.

Copy link
Member

Choose a reason for hiding this comment

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

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 add a check in ResizeFileShare func

@@ -21,17 +21,19 @@ import (
"os"
"runtime"

"k8s.io/apimachinery/pkg/api/resource"
Copy link
Member

Choose a reason for hiding this comment

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

nit: group import with prefix, e.g. k8s.io and others

Copy link
Member Author

Choose a reason for hiding this comment

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

it's made by IDE automatically...

Copy link
Contributor

Choose a reason for hiding this comment

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

if remove the empty lines, gofmt will auto do the sort.

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

@@ -72,3 +72,19 @@ func (az *Cloud) DeleteFileShare(accountName, key, name string) error {
return nil

}

// ResizeFileShare resize a file share
Copy link
Contributor

Choose a reason for hiding this comment

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

resizes

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

"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/kubernetes/pkg/util/mount"
kstrings "k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
Copy link
Contributor

Choose a reason for hiding this comment

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

can we sort this import? literals k8s.io and github.com are mixed now

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

@feiskyer feiskyer self-assigned this Jan 22, 2018
@@ -139,6 +142,42 @@ func (plugin *azureFilePlugin) newUnmounterInternal(volName string, podUID types
}}, nil
}

func (plugin *azureFilePlugin) RequiresFSResize() bool {
return false
Copy link
Contributor

Choose a reason for hiding this comment

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

Will not call resize if set to false?

expandableVolumePlugin.RequiresFSResize() &&

Copy link
Member Author

Choose a reason for hiding this comment

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

RequiresFSResize means require file system resize, azure file don't need this. this value of Azure disk should be true.

newSize resource.Quantity,
oldSize resource.Quantity) (resource.Quantity, error) {

if spec.PersistentVolume != nil && spec.PersistentVolume.Spec.AzureFile == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

better be spec.PersistentVolume==nil || ...

Otherwise if spec.PersistentVolume is nil, Line#157 will raise null reference exception.

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch, fixed.

@@ -41,6 +41,8 @@ type azureCloudProvider interface {
CreateFileShare(name, storageAccount, storageType, location string, requestGB int) (string, string, error)
// delete a file share
DeleteFileShare(accountName, key, name string) error
// resize a file share
ResizeFileShare(accountName, accountKey, name string, sizeGiB int64) error
Copy link
Contributor

@karataliu karataliu Jan 22, 2018

Choose a reason for hiding this comment

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

ResizeFileShare uses sizeGiB here, CreateFileShare uses 'requestGB', that may be confusing. Since both use 'GiB' in in reality, consider renaming requestGB to sizeGiB.

@andyzhangx
Copy link
Member Author

@gnufied @feiskyer @karataliu PTAL, thanks.

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
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 22, 2018
@andyzhangx
Copy link
Member Author

/assign @brendandburns PTAL, some code is out of Azure code

@gnufied
Copy link
Member

gnufied commented Jan 22, 2018

/lgtm

@jdumars
Copy link
Member

jdumars commented Jan 22, 2018

/cc @brendandburns

@andyzhangx
Copy link
Member Author

/test pull-kubernetes-e2e-gce

@andyzhangx
Copy link
Member Author

@brendandburns PTAL, some code is out of Azure code

@andyzhangx
Copy link
Member Author

/assign @brendandburns PTAL

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 30, 2018
enable azure file grow size

fix according to comments

fix comments

fix review comments

fix comments
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 30, 2018
@k8s-github-robot k8s-github-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jan 30, 2018
@andyzhangx
Copy link
Member Author

/test pull-kubernetes-bazel-test

fix test build failure
@andyzhangx
Copy link
Member Author

@feiskyer @brendandburns rebased, PTAL.

@feiskyer
Copy link
Member

feiskyer commented Feb 1, 2018

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 1, 2018
@rootfs
Copy link
Contributor

rootfs commented Feb 5, 2018

/assign @deads2k for approval

@deads2k
Copy link
Contributor

deads2k commented Feb 5, 2018

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andyzhangx, deads2k, feiskyer, gnufied

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-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 5, 2018
@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit ffda1e2 into kubernetes:master Feb 5, 2018
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add PV resize support for azure file