diff --git a/Godeps/LICENSES b/Godeps/LICENSES index a7832673562..a9dcfe842e9 100644 --- a/Godeps/LICENSES +++ b/Godeps/LICENSES @@ -8767,7 +8767,7 @@ SOFTWARE. ================================================================================ -= vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage licensed under: = += vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage licensed under: = Apache License @@ -10648,6 +10648,205 @@ THE SOFTWARE. ================================================================================ +================================================================================ += vendor/github.com/Azure/go-autorest/logger licensed under: = + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2015 Microsoft Corporation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + += vendor/github.com/Azure/go-autorest/LICENSE a250e5ac3848f2acadb5adcb9555c18b +================================================================================ + + ================================================================================ = vendor/github.com/Azure/go-autorest/version licensed under: = diff --git a/pkg/cloudprovider/providers/azure/azure_blobDiskController.go b/pkg/cloudprovider/providers/azure/azure_blobDiskController.go index d3ad1ed990c..6ecc8bf4437 100644 --- a/pkg/cloudprovider/providers/azure/azure_blobDiskController.go +++ b/pkg/cloudprovider/providers/azure/azure_blobDiskController.go @@ -80,7 +80,7 @@ func newBlobDiskController(common *controllerCommon) (*BlobDiskController, error // If no storage account is given, search all the storage accounts associated with the resource group and pick one that // fits storage type and location. func (c *BlobDiskController) CreateVolume(blobName, accountName, accountType, location string, requestGB int) (string, string, int, error) { - account, key, err := c.common.cloud.ensureStorageAccount(accountName, accountType, c.common.resourceGroup, location, dedicatedDiskAccountNamePrefix) + account, key, err := c.common.cloud.ensureStorageAccount(accountName, accountType, string(defaultStorageAccountKind), c.common.resourceGroup, location, dedicatedDiskAccountNamePrefix) if err != nil { return "", "", 0, fmt.Errorf("could not get storage key for storage account %s: %v", accountName, err) } @@ -491,7 +491,7 @@ func (c *BlobDiskController) createStorageAccount(storageAccountName string, sto cp := storage.AccountCreateParameters{ Sku: &storage.Sku{Name: storageAccountType}, // switch to use StorageV2 as it's recommended according to https://docs.microsoft.com/en-us/azure/storage/common/storage-account-options - Kind: storage.StorageV2, + Kind: defaultStorageAccountKind, Tags: map[string]*string{"created-by": to.StringPtr("azure-dd")}, Location: &location} ctx, cancel := getContextWithCancel() diff --git a/pkg/cloudprovider/providers/azure/azure_file.go b/pkg/cloudprovider/providers/azure/azure_file.go index 138dabb5765..f5bec74cb25 100644 --- a/pkg/cloudprovider/providers/azure/azure_file.go +++ b/pkg/cloudprovider/providers/azure/azure_file.go @@ -58,22 +58,11 @@ func (f *azureFileClient) createFileShare(accountName, accountKey, name string, if err != nil { return err } - // create a file share and set quota - // Note. Per https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Create-Share, - // setting x-ms-share-quota can set quota on the new share, but in reality, setting quota in CreateShare - // receives error "The metadata specified is invalid. It has characters that are not permitted." - // As a result,breaking into two API calls: create share and set quota share := fileClient.GetShareReference(name) + share.Properties.Quota = sizeGiB if err = share.Create(nil); err != nil { return fmt.Errorf("failed to create file share, err: %v", err) } - share.Properties.Quota = sizeGiB - if err = share.SetProperties(nil); err != nil { - if err := share.Delete(nil); err != nil { - glog.Errorf("Error deleting share: %v", err) - } - return fmt.Errorf("failed to set quota on file share %s, err: %v", name, err) - } return nil } diff --git a/pkg/cloudprovider/providers/azure/azure_storage.go b/pkg/cloudprovider/providers/azure/azure_storage.go index 4f797890f88..7c95487be26 100644 --- a/pkg/cloudprovider/providers/azure/azure_storage.go +++ b/pkg/cloudprovider/providers/azure/azure_storage.go @@ -25,18 +25,20 @@ import ( const ( defaultStorageAccountType = string(storage.StandardLRS) + defaultStorageAccountKind = storage.StorageV2 fileShareAccountNamePrefix = "f" sharedDiskAccountNamePrefix = "ds" dedicatedDiskAccountNamePrefix = "dd" ) -// CreateFileShare creates a file share, using a matching storage account -func (az *Cloud) CreateFileShare(shareName, accountName, accountType, resourceGroup, location string, requestGiB int) (string, string, error) { +// CreateFileShare creates a file share, using a matching storage account type, account kind, etc. +// storage account will be created if specified account is not found +func (az *Cloud) CreateFileShare(shareName, accountName, accountType, accountKind, resourceGroup, location string, requestGiB int) (string, string, error) { if resourceGroup == "" { resourceGroup = az.resourceGroup } - account, key, err := az.ensureStorageAccount(accountName, accountType, resourceGroup, location, fileShareAccountNamePrefix) + account, key, err := az.ensureStorageAccount(accountName, accountType, accountKind, resourceGroup, location, fileShareAccountNamePrefix) if err != nil { return "", "", fmt.Errorf("could not get storage key for storage account %s: %v", accountName, err) } diff --git a/pkg/cloudprovider/providers/azure/azure_storage_test.go b/pkg/cloudprovider/providers/azure/azure_storage_test.go index bc36736492b..ca70e76d1c5 100644 --- a/pkg/cloudprovider/providers/azure/azure_storage_test.go +++ b/pkg/cloudprovider/providers/azure/azure_storage_test.go @@ -30,6 +30,7 @@ func TestCreateFileShare(t *testing.T) { name := "baz" sku := "sku" + kind := "StorageV2" location := "centralus" value := "foo key" bogus := "bogus" @@ -38,6 +39,7 @@ func TestCreateFileShare(t *testing.T) { name string acct string acctType string + acctKind string loc string gb int accounts storage.AccountListResult @@ -52,6 +54,7 @@ func TestCreateFileShare(t *testing.T) { name: "foo", acct: "bar", acctType: "type", + acctKind: "StorageV2", loc: "eastus", gb: 10, expectErr: true, @@ -60,6 +63,7 @@ func TestCreateFileShare(t *testing.T) { name: "foo", acct: "", acctType: "type", + acctKind: "StorageV2", loc: "eastus", gb: 10, expectErr: true, @@ -68,11 +72,12 @@ func TestCreateFileShare(t *testing.T) { name: "foo", acct: "", acctType: sku, + acctKind: kind, loc: location, gb: 10, accounts: storage.AccountListResult{ Value: &[]storage.Account{ - {Name: &name, Sku: &storage.Sku{Name: storage.SkuName(sku)}, Location: &location}, + {Name: &name, Sku: &storage.Sku{Name: storage.SkuName(sku)}, Kind: storage.Kind(kind), Location: &location}, }, }, keys: storage.AccountListKeysResult{ @@ -87,6 +92,7 @@ func TestCreateFileShare(t *testing.T) { name: "foo", acct: "", acctType: sku, + acctKind: kind, loc: location, gb: 10, accounts: storage.AccountListResult{ @@ -100,6 +106,7 @@ func TestCreateFileShare(t *testing.T) { name: "foo", acct: "", acctType: sku, + acctKind: kind, loc: location, gb: 10, accounts: storage.AccountListResult{ @@ -116,7 +123,7 @@ func TestCreateFileShare(t *testing.T) { fake.Keys = test.keys fake.Err = test.err - account, key, err := cloud.CreateFileShare(test.name, test.acct, test.acctType, "rg", test.loc, test.gb) + account, key, err := cloud.CreateFileShare(test.name, test.acct, test.acctType, test.acctKind, "rg", test.loc, test.gb) if test.expectErr && err == nil { t.Errorf("unexpected non-error") continue diff --git a/pkg/cloudprovider/providers/azure/azure_storageaccount.go b/pkg/cloudprovider/providers/azure/azure_storageaccount.go index c3521775e3a..f0d50091474 100644 --- a/pkg/cloudprovider/providers/azure/azure_storageaccount.go +++ b/pkg/cloudprovider/providers/azure/azure_storageaccount.go @@ -30,7 +30,7 @@ type accountWithLocation struct { } // getStorageAccounts gets name, type, location of all storage accounts in a resource group which matches matchingAccountType, matchingLocation -func (az *Cloud) getStorageAccounts(matchingAccountType, resourceGroup, matchingLocation string) ([]accountWithLocation, error) { +func (az *Cloud) getStorageAccounts(matchingAccountType, matchingAccountKind, resourceGroup, matchingLocation string) ([]accountWithLocation, error) { ctx, cancel := getContextWithCancel() defer cancel() result, err := az.StorageAccountClient.ListByResourceGroup(ctx, resourceGroup) @@ -49,6 +49,10 @@ func (az *Cloud) getStorageAccounts(matchingAccountType, resourceGroup, matching continue } + if matchingAccountKind != "" && !strings.EqualFold(matchingAccountKind, string(acct.Kind)) { + continue + } + location := *acct.Location if matchingLocation != "" && !strings.EqualFold(matchingLocation, location) { continue @@ -86,10 +90,10 @@ func (az *Cloud) getStorageAccesskey(account, resourceGroup string) (string, err } // ensureStorageAccount search storage account, create one storage account(with genAccountNamePrefix) if not found, return accountName, accountKey -func (az *Cloud) ensureStorageAccount(accountName, accountType, resourceGroup, location, genAccountNamePrefix string) (string, string, error) { +func (az *Cloud) ensureStorageAccount(accountName, accountType, accountKind, resourceGroup, location, genAccountNamePrefix string) (string, string, error) { if len(accountName) == 0 { // find a storage account that matches accountType - accounts, err := az.getStorageAccounts(accountType, resourceGroup, location) + accounts, err := az.getStorageAccounts(accountType, accountKind, resourceGroup, location) if err != nil { return "", "", fmt.Errorf("could not list storage accounts for account type %s: %v", accountType, err) } @@ -109,12 +113,16 @@ func (az *Cloud) ensureStorageAccount(accountName, accountType, resourceGroup, l accountType = defaultStorageAccountType } - glog.V(2).Infof("azure - no matching account found, begin to create a new account %s in resource group %s, location: %s, accountType: %s", - accountName, resourceGroup, location, accountType) + // use StorageV2 by default per https://docs.microsoft.com/en-us/azure/storage/common/storage-account-options + kind := defaultStorageAccountKind + if accountKind != "" { + kind = storage.Kind(accountKind) + } + glog.V(2).Infof("azure - no matching account found, begin to create a new account %s in resource group %s, location: %s, accountType: %s, accountKind: %s", + accountName, resourceGroup, location, accountType, kind) cp := storage.AccountCreateParameters{ - Sku: &storage.Sku{Name: storage.SkuName(accountType)}, - // switch to use StorageV2 as it's recommended according to https://docs.microsoft.com/en-us/azure/storage/common/storage-account-options - Kind: storage.StorageV2, + Sku: &storage.Sku{Name: storage.SkuName(accountType)}, + Kind: kind, AccountPropertiesCreateParameters: &storage.AccountPropertiesCreateParameters{EnableHTTPSTrafficOnly: to.BoolPtr(true)}, Tags: map[string]*string{"created-by": to.StringPtr("azure")}, Location: &location} diff --git a/pkg/volume/azure_file/BUILD b/pkg/volume/azure_file/BUILD index 8a9b24239fb..3f278c7b227 100644 --- a/pkg/volume/azure_file/BUILD +++ b/pkg/volume/azure_file/BUILD @@ -27,6 +27,7 @@ go_library( "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//staging/src/k8s.io/cloud-provider:go_default_library", + "//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage:go_default_library", "//vendor/github.com/golang/glog:go_default_library", ], ) diff --git a/pkg/volume/azure_file/azure_provision.go b/pkg/volume/azure_file/azure_provision.go index d3281d70bae..96ba0b10cc9 100644 --- a/pkg/volume/azure_file/azure_provision.go +++ b/pkg/volume/azure_file/azure_provision.go @@ -20,7 +20,9 @@ import ( "fmt" "strings" + "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage" "github.com/golang/glog" + "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -38,7 +40,7 @@ var _ volume.ProvisionableVolumePlugin = &azureFilePlugin{} // azure cloud provider should implement it type azureCloudProvider interface { // create a file share - CreateFileShare(shareName, accountName, accountType, resourceGroup, location string, requestGiB int) (string, string, error) + CreateFileShare(shareName, accountName, accountType, accountKind, resourceGroup, location string, requestGiB int) (string, string, error) // delete a file share DeleteFileShare(accountName, accountKey, shareName string) error // resize a file share @@ -171,7 +173,12 @@ func (a *azureFileProvisioner) Provision(selectedNode *v1.Node, allowedTopologie return nil, fmt.Errorf("claim.Spec.Selector is not supported for dynamic provisioning on Azure file") } - account, key, err := a.azureProvider.CreateFileShare(name, account, sku, resourceGroup, location, requestGiB) + // when use azure file premium, account kind should be specified as FileStorage + accountKind := string(storage.StorageV2) + if strings.HasPrefix(strings.ToLower(sku), "premium") { + accountKind = string(storage.FileStorage) + } + account, key, err := a.azureProvider.CreateFileShare(name, account, sku, accountKind, resourceGroup, location, requestGiB) if err != nil { return nil, err } diff --git a/staging/src/k8s.io/client-go/Godeps/Godeps.json b/staging/src/k8s.io/client-go/Godeps/Godeps.json index 9076b4032cb..29cb8fb92f5 100644 --- a/staging/src/k8s.io/client-go/Godeps/Godeps.json +++ b/staging/src/k8s.io/client-go/Godeps/Godeps.json @@ -16,23 +16,27 @@ }, { "ImportPath": "github.com/Azure/go-autorest/autorest", - "Rev": "bca49d5b51a50dc5bb17bbf6204c711c6dbded06" + "Rev": "a88c19ef2016e095f0b6c3b451074b4663f53bed" }, { "ImportPath": "github.com/Azure/go-autorest/autorest/adal", - "Rev": "bca49d5b51a50dc5bb17bbf6204c711c6dbded06" + "Rev": "a88c19ef2016e095f0b6c3b451074b4663f53bed" }, { "ImportPath": "github.com/Azure/go-autorest/autorest/azure", - "Rev": "bca49d5b51a50dc5bb17bbf6204c711c6dbded06" + "Rev": "a88c19ef2016e095f0b6c3b451074b4663f53bed" }, { "ImportPath": "github.com/Azure/go-autorest/autorest/date", - "Rev": "bca49d5b51a50dc5bb17bbf6204c711c6dbded06" + "Rev": "a88c19ef2016e095f0b6c3b451074b4663f53bed" + }, + { + "ImportPath": "github.com/Azure/go-autorest/logger", + "Rev": "a88c19ef2016e095f0b6c3b451074b4663f53bed" }, { "ImportPath": "github.com/Azure/go-autorest/version", - "Rev": "bca49d5b51a50dc5bb17bbf6204c711c6dbded06" + "Rev": "a88c19ef2016e095f0b6c3b451074b4663f53bed" }, { "ImportPath": "github.com/davecgh/go-spew/spew",