From bf0c6d84f57bdb9388d9d29356a6c1a638a48375 Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Tue, 30 Jan 2018 14:02:49 +0000 Subject: [PATCH] fix rebase error fix test build failure --- .../providers/azure/azure_fakes.go | 6 ++++- .../providers/azure/azure_file.go | 24 +++++++++++++++++++ .../providers/azure/azure_storage.go | 18 +------------- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/pkg/cloudprovider/providers/azure/azure_fakes.go b/pkg/cloudprovider/providers/azure/azure_fakes.go index ac30a533abb..cad1ad47978 100644 --- a/pkg/cloudprovider/providers/azure/azure_fakes.go +++ b/pkg/cloudprovider/providers/azure/azure_fakes.go @@ -930,7 +930,7 @@ func (fRTC *fakeRouteTablesClient) Get(resourceGroupName string, routeTableName type fakeFileClient struct { } -func (fFC *fakeFileClient) createFileShare(accountName, accountKey, name string, sizeGB int) error { +func (fFC *fakeFileClient) createFileShare(accountName, accountKey, name string, sizeGiB int) error { return nil } @@ -938,6 +938,10 @@ func (fFC *fakeFileClient) deleteFileShare(accountName, accountKey, name string) return nil } +func (fFC *fakeFileClient) resizeFileShare(accountName, accountKey, name string, sizeGiB int) error { + return nil +} + type fakeStorageAccountClient struct { mutex *sync.Mutex FakeStore map[string]map[string]storage.Account diff --git a/pkg/cloudprovider/providers/azure/azure_file.go b/pkg/cloudprovider/providers/azure/azure_file.go index 1afb78015a5..138dabb5765 100644 --- a/pkg/cloudprovider/providers/azure/azure_file.go +++ b/pkg/cloudprovider/providers/azure/azure_file.go @@ -33,6 +33,7 @@ const ( type FileClient interface { createFileShare(accountName, accountKey, name string, sizeGiB int) error deleteFileShare(accountName, accountKey, name string) error + resizeFileShare(accountName, accountKey, name string, sizeGiB int) error } // create file share @@ -44,6 +45,10 @@ func (az *Cloud) deleteFileShare(accountName, accountKey, name string) error { return az.FileClient.deleteFileShare(accountName, accountKey, name) } +func (az *Cloud) resizeFileShare(accountName, accountKey, name string, sizeGiB int) error { + return az.FileClient.resizeFileShare(accountName, accountKey, name, sizeGiB) +} + type azureFileClient struct { env azure.Environment } @@ -81,6 +86,25 @@ func (f *azureFileClient) deleteFileShare(accountName, accountKey, name string) return fileClient.GetShareReference(name).Delete(nil) } +func (f *azureFileClient) resizeFileShare(accountName, accountKey, name string, sizeGiB int) error { + fileClient, err := f.getFileSvcClient(accountName, accountKey) + if err != nil { + return err + } + share := fileClient.GetShareReference(name) + if share.Properties.Quota >= sizeGiB { + glog.Warningf("file share size(%dGi) is already greater or equal than requested size(%dGi), accountName: %s, shareName: %s", + share.Properties.Quota, sizeGiB, accountName, name) + return nil + } + share.Properties.Quota = sizeGiB + if err = share.SetProperties(nil); err != nil { + return fmt.Errorf("failed to set quota on file share %s, err: %v", name, err) + } + glog.V(4).Infof("resize file share completed, accountName: %s, shareName: %s, sizeGiB: %d", accountName, name, sizeGiB) + return nil +} + func (f *azureFileClient) getFileSvcClient(accountName, accountKey string) (*azs.FileServiceClient, error) { fileClient, err := azs.NewClient(accountName, accountKey, f.env.StorageEndpointSuffix, azs.DefaultAPIVersion, useHTTPS) if err != nil { diff --git a/pkg/cloudprovider/providers/azure/azure_storage.go b/pkg/cloudprovider/providers/azure/azure_storage.go index 5be1fd73718..ab5f820ff6e 100644 --- a/pkg/cloudprovider/providers/azure/azure_storage.go +++ b/pkg/cloudprovider/providers/azure/azure_storage.go @@ -72,21 +72,5 @@ func (az *Cloud) DeleteFileShare(accountName, key, name string) error { // ResizeFileShare resizes a file share func (az *Cloud) ResizeFileShare(accountName, accountKey, name string, sizeGiB int) error { - fileClient, err := az.getFileSvcClient(accountName, accountKey) - if err != nil { - return err - } - - share := fileClient.GetShareReference(name) - if share.Properties.Quota >= sizeGiB { - glog.Warningf("file share size(%dGi) is already greater or equal than requested size(%dGi), accountName: %s, shareName: %s", - share.Properties.Quota, sizeGiB, accountName, name) - return nil - } - share.Properties.Quota = sizeGiB - if err = share.SetProperties(nil); err != nil { - return fmt.Errorf("failed to set quota on file share %s, err: %v", name, err) - } - glog.V(4).Infof("resize file share completed, accountName: %s, shareName: %s, sizeGiB: %d", accountName, name, sizeGiB) - return nil + return az.resizeFileShare(accountName, accountKey, name, sizeGiB) }