From a3506c8e16ebb528bdbf80679805fe69b8c0904e Mon Sep 17 00:00:00 2001 From: Cosmin Cojocar Date: Mon, 17 Jul 2017 09:05:03 +0200 Subject: [PATCH] Fall back on Azure public cloud endpoint when no Azure cloud provider is found --- pkg/volume/azure_file/azure_file.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pkg/volume/azure_file/azure_file.go b/pkg/volume/azure_file/azure_file.go index d486c7d12c0..5c5fb4395c2 100644 --- a/pkg/volume/azure_file/azure_file.go +++ b/pkg/volume/azure_file/azure_file.go @@ -210,11 +210,7 @@ func (b *azureFileMounter) SetUpAt(dir string, fsGroup *int64) error { } os.MkdirAll(dir, 0750) - azure, err := getAzureCloud(b.plugin.host.GetCloudProvider()) - if err != nil { - return err - } - source := fmt.Sprintf("//%s.file.%s/%s", accountName, azure.Environment.StorageEndpointSuffix, b.shareName) + source := fmt.Sprintf("//%s.file.%s/%s", accountName, getStorageEndpointSuffix(b.plugin.host.GetCloudProvider()), b.shareName) // 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=0777,file_mode=0777", accountName, accountKey)} if b.readOnly { @@ -284,3 +280,13 @@ func getAzureCloud(cloudProvider cloudprovider.Interface) (*azure.Cloud, error) return azure, nil } + +func getStorageEndpointSuffix(cloudprovider cloudprovider.Interface) string { + const publicCloudStorageEndpointSuffix = "core.windows.net" + azure, err := getAzureCloud(cloudprovider) + if err == nil { + glog.Warningf("No Azure cloud provider found. Using the Azure public cloud endpoint: %s", publicCloudStorageEndpointSuffix) + return publicCloudStorageEndpointSuffix + } + return azure.Environment.StorageEndpointSuffix +}