-
Notifications
You must be signed in to change notification settings - Fork 40k
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
add PV size grow feature for azure file #57017
Conversation
/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 { |
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.
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...
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.
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
@gnufied PTAL |
@gnufied PTAL, thanks |
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.
Mostly looks okay. needs some minor changes
pkg/volume/azure_file/azure_file.go
Outdated
shareName := spec.PersistentVolume.Spec.AzureFile.ShareName | ||
azure, err := getAzureCloudProvider(plugin.host.GetCloudProvider()) | ||
if err != nil { | ||
glog.V(2).Infof("failed to get azure provider") |
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.
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
?
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.
good catch, actually it's not necessary, I have removed those info logs
pkg/volume/azure_file/azure_file.go
Outdated
|
||
secretName, secretNamespace, err := getSecretNameAndNamespace(spec, spec.PersistentVolume.Spec.ClaimRef.Namespace) | ||
if err != nil { | ||
glog.V(2).Infof("failed to get secret") |
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.
same as before 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.
fixed
pkg/volume/azure_file/azure_file.go
Outdated
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) |
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.
ditto
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.
removed
pkg/volume/azure_file/azure_file.go
Outdated
return oldSize, err | ||
} | ||
|
||
if err := azure.ResizeFileShare(accountName, accountKey, shareName, int(newSize.Value()/1024/1024/1024)); err != 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.
Can you use - https://github.com/kubernetes/kubernetes/blob/master/pkg/volume/util.go#L303 rather than dividing by 1024**3 ?
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
} | ||
|
||
share := fileClient.GetShareReference(name) | ||
share.Properties.Quota = sizeGB |
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.
Is it GB or GiB? It appears that you are passing GiB value from other place.
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.
thanks for checking, it's GiB, have changed the var name
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.
@gnufied thanks for the review. PTAL.
Next I will work on azure disk resize.
} | ||
|
||
share := fileClient.GetShareReference(name) | ||
share.Properties.Quota = sizeGB |
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.
thanks for checking, it's GiB, have changed the var name
pkg/volume/azure_file/azure_file.go
Outdated
shareName := spec.PersistentVolume.Spec.AzureFile.ShareName | ||
azure, err := getAzureCloudProvider(plugin.host.GetCloudProvider()) | ||
if err != nil { | ||
glog.V(2).Infof("failed to get azure provider") |
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.
good catch, actually it's not necessary, I have removed those info logs
pkg/volume/azure_file/azure_file.go
Outdated
|
||
secretName, secretNamespace, err := getSecretNameAndNamespace(spec, spec.PersistentVolume.Spec.ClaimRef.Namespace) | ||
if err != nil { | ||
glog.V(2).Infof("failed to get secret") |
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_file.go
Outdated
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) |
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.
removed
pkg/volume/azure_file/azure_file.go
Outdated
return oldSize, err | ||
} | ||
|
||
if err := azure.ResizeFileShare(accountName, accountKey, shareName, int(newSize.Value()/1024/1024/1024)); err != 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.
fixed
78ecdbf
to
fe6a549
Compare
@karataliu @feiskyer PTAL, thx |
pkg/volume/azure_file/azure_file.go
Outdated
if err != nil { | ||
return oldSize, err | ||
} | ||
|
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.
Add a check of whether newSize is greater than oldSize?
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.
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.
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.
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 add a check in ResizeFileShare func
pkg/volume/azure_file/azure_file.go
Outdated
@@ -21,17 +21,19 @@ import ( | |||
"os" | |||
"runtime" | |||
|
|||
"k8s.io/apimachinery/pkg/api/resource" |
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: group import with prefix, e.g. k8s.io
and others
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.
it's made by IDE automatically...
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.
if remove the empty lines, gofmt will auto do the sort.
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
@@ -72,3 +72,19 @@ func (az *Cloud) DeleteFileShare(accountName, key, name string) error { | |||
return nil | |||
|
|||
} | |||
|
|||
// ResizeFileShare resize a file share |
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.
resizes
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_file.go
Outdated
"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" |
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 sort this import? literals k8s.io
and github.com
are mixed now
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
@@ -139,6 +142,42 @@ func (plugin *azureFilePlugin) newUnmounterInternal(volName string, podUID types | |||
}}, nil | |||
} | |||
|
|||
func (plugin *azureFilePlugin) RequiresFSResize() bool { | |||
return false |
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.
Will not call resize if set to false?
expandableVolumePlugin.RequiresFSResize() && |
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.
RequiresFSResize
means require file system resize, azure file don't need this. this value of Azure disk should be true.
pkg/volume/azure_file/azure_file.go
Outdated
newSize resource.Quantity, | ||
oldSize resource.Quantity) (resource.Quantity, error) { | ||
|
||
if spec.PersistentVolume != nil && spec.PersistentVolume.Spec.AzureFile == 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.
better be spec.PersistentVolume==nil || ...
Otherwise if spec.PersistentVolume is nil, Line#157 will raise null reference exception.
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.
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 |
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.
ResizeFileShare uses sizeGiB
here, CreateFileShare uses 'requestGB', that may be confusing. Since both use 'GiB' in in reality, consider renaming requestGB
to sizeGiB
.
@gnufied @feiskyer @karataliu PTAL, thanks. |
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
/approve
/assign @brendandburns PTAL, some code is out of Azure code |
/lgtm |
/cc @brendandburns |
/test pull-kubernetes-e2e-gce |
@brendandburns PTAL, some code is out of Azure code |
/assign @brendandburns PTAL |
enable azure file grow size fix according to comments fix comments fix review comments fix comments
76ad030
to
8a645f2
Compare
/test pull-kubernetes-bazel-test |
fix test build failure
8a645f2
to
bf0c6d8
Compare
@feiskyer @brendandburns rebased, PTAL. |
/lgtm |
/assign @deads2k for approval |
/approve |
[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 |
/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:
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:
/sig azure
@gnufied @rootfs @brendandburns