-
Notifications
You must be signed in to change notification settings - Fork 832
Support azure storage of azurechina,azuregerman,azureusgov #2988
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
Support azure storage of azurechina,azuregerman,azureusgov #2988
Conversation
Signed-off-by: Binbin Zou <[email protected]>
Signed-off-by: Binbin Zou <[email protected]>
7350dd6
to
6c2ea12
Compare
Add support for other Azure Clouds On #1319 |
@khaines Hi haines, please review if you are free. |
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 @zbbkeepgoing for working on this! ❤️
I left few comments. Most are minor things, but please be aware that CircleCI for this PR is failing to run: could you try to login to https://circleci.com/ with your GitHub account and follow the cortexproject there before submitting your next commit, please?
I'm marking this PR as "request changes" mainly to signal CI hasn't run.
// BlobStorageConfig defines the configurable flags that can be defined when using azure blob storage. | ||
type BlobStorageConfig struct { | ||
CloudEnvironment string `yaml:"cloud_environment"` |
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.
What if we simply call it environment
?
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.
done
@@ -41,6 +55,7 @@ func (c *BlobStorageConfig) RegisterFlags(f *flag.FlagSet) { | |||
|
|||
// RegisterFlagsWithPrefix adds the flags required to config this to the given FlagSet | |||
func (c *BlobStorageConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) { | |||
f.StringVar(&c.CloudEnvironment, prefix+"azure.cloud_environment", "AzureGlobal", "Environment of Azure Cloud. This value can be AzureGlobal, AzureChinaCloud, AzureGermanCloud, AzureUSGovernment.") |
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.
We have a convention to use _
in YAML and -
in CLI flags. Here it should be cloud-environment
, even if I would suggest to just call it environment
.
Also if you have a constant for AzureGlobal
and the other environments and you create a global slice variable with all supported environments, then here you could dinamically generate it using strings.Join(supportedEnvironments, ",")
.
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.
done
const blobURLFmt = "https://%s.blob.core.windows.net/%s/%s" | ||
const containerURLFmt = "https://%s.blob.core.windows.net/%s" |
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.
Could you prefix these by global
, please?
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.
done
|
||
func (b *BlobStorage) selectBlobUrlFmt() string { | ||
switch b.cfg.CloudEnvironment { | ||
case "AzureGlobal": |
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.
Could you create constants for these AzureGlobal
, AzureChinaCloud
, etc please?
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.
done
CHANGELOG.md
Outdated
@@ -46,6 +46,7 @@ | |||
- `-experimental.tsdb.flush-blocks-on-shutdown` changed to `-experimental.blocks-storage.tsdb.flush-blocks-on-shutdown` | |||
* [CHANGE] Flags `-bigtable.grpc-use-gzip-compression`, `-ingester.client.grpc-use-gzip-compression`, `-querier.frontend-client.grpc-use-gzip-compression` are now deprecated. #2940 | |||
* [CHANGE] Limit errors reported by ingester during query-time now return HTTP status code 422. #2941 | |||
* [FEATURE] Add support for azure storage of AzureChinaCloud,AzureGermanCloud,AzureUSGovernment. #2988 |
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.
Please move the CHANGELOG entry to the top, under "master / unrelease". This is the section for 1.3.0 which has already been cut. 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.
done
"github.com/cortexproject/cortex/pkg/util/flagext" | ||
) | ||
|
||
func TestGetObject(t *testing.T) { |
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 tried to run these tests locally, but looks failing with the error illegal base64 data at input byte 8
. Also I'm not sure how they're supposed to work, considering the backend storage is not mocked 🤔
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.
Yes, I think it is difficult for me to mock azure storage, so I deleted the test file 😂
… feature/azure-storage-others-cloud
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 @zbbkeepgoing for addressing my feedback. I left a last round of feedback and then we should be good to go. Thanks!
|
||
// Validate the config. | ||
func (c *BlobStorageConfig) Validate() error { | ||
if c.Environment != azureGlobal && c.Environment != azureChinaCloud && c.Environment != azureGermanCloud && c.Environment == azureUSGovernment { |
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.
You can use supportedEnvironments
here:
if !util.StringsContain(supportedEnvironments, c.Environment) {
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.
done
// Validate the config. | ||
func (c *BlobStorageConfig) Validate() error { | ||
if c.Environment != azureGlobal && c.Environment != azureChinaCloud && c.Environment != azureGermanCloud && c.Environment == azureUSGovernment { | ||
return fmt.Errorf("unsupported environment: %s, please select one of: %s ", c.Environment, strings.Join(supportedEnvironments, ",")) |
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.
return fmt.Errorf("unsupported environment: %s, please select one of: %s ", c.Environment, strings.Join(supportedEnvironments, ",")) | |
return fmt.Errorf("unsupported Azure blob storage environment: %s, please select one of: %s ", c.Environment, strings.Join(supportedEnvironments, ", ")) |
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.
done
@@ -41,6 +69,7 @@ func (c *BlobStorageConfig) RegisterFlags(f *flag.FlagSet) { | |||
|
|||
// RegisterFlagsWithPrefix adds the flags required to config this to the given FlagSet | |||
func (c *BlobStorageConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) { | |||
f.StringVar(&c.Environment, prefix+"azure.environment", azureGlobal, fmt.Sprintf("Environment of Azure Cloud. This value can be %s.", strings.Join(supportedEnvironments, ","))) |
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.
f.StringVar(&c.Environment, prefix+"azure.environment", azureGlobal, fmt.Sprintf("Environment of Azure Cloud. This value can be %s.", strings.Join(supportedEnvironments, ","))) | |
f.StringVar(&c.Environment, prefix+"azure.environment", azureGlobal, fmt.Sprintf("Azure Cloud environment. Supported values are: %s.", strings.Join(supportedEnvironments, ", "))) |
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.
done
) | ||
|
||
// Environment | ||
const ( |
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.
Merge the two const
please.
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.
done
f4fd5b9
to
492095a
Compare
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 (modulo fixing the linter issue), thanks! @pstibrany could you take a second look, please?
Signed-off-by: Binbin Zou <[email protected]>
492095a
to
c5d97d6
Compare
Signed-off-by: Binbin Zou <[email protected]>
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, thank you! I've left two non-blocking comments.
CHANGELOG.md
Outdated
@@ -1,7 +1,7 @@ | |||
# Changelog | |||
|
|||
## master / unreleased | |||
|
|||
* [ENHANCEMENT] Add support for azure storage of AzureChinaCloud,AzureGermanCloud,AzureUSGovernment. #2988 |
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.
* [ENHANCEMENT] Add support for azure storage of AzureChinaCloud,AzureGermanCloud,AzureUSGovernment. #2988 | |
* [ENHANCEMENT] Add support for azure storage in China, German and US Government environments. #2988 |
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.
done
//Blob service endpoint of AzureGlobal | ||
globalBlobURLFmt = "https://%s.blob.core.windows.net/%s/%s" | ||
globalContainerURLFmt = "https://%s.blob.core.windows.net/%s" | ||
|
||
// Blob service endpoint of AzureChinaCloud | ||
chinaBlobURLFmt = "https://%s.blob.core.chinacloudapi.cn/%s/%s" | ||
chinaContainerURLFmt = "https://%s.blob.core.chinacloudapi.cn/%s" | ||
|
||
// Blob service endpoint of AzureGermanCloud | ||
germanyBlobURLFmt = "https://%s.blob.core.cloudapi.de/%s/%s" | ||
germanyContainerURLFmt = "https://%s.blob.core.cloudapi.de/%s" | ||
|
||
// Blob service endpoint of AzureUSGovernment | ||
govBlobURLFmt = "https://%s.blob.core.usgovcloudapi.net/%s/%s" | ||
govContainerURLFmt = "https://%s.blob.core.usgovcloudapi.net/%s" |
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'm trying to verify these endpoints, but cannot find authoritative summary documentation. Do you have any relevant link?
Would it make sense to use something like:
var endpoints = map[string]struct{blobURL, containerURL string} {
azureGlobal: {
blobURL: "https://%s.blob.core.windows.net/%s/%s",
containerURL: "https://%s.blob.core.windows.net/%s",
},
azureChinaCloud: {
blobURL: "https://%s.blob.core.chinacloudapi.cn/%s/%s",
containerURL: "https://%s.blob.core.chinacloudapi.cn/%s",
},
// ...
}
and then use the map instead of selectBlobURLFmt
and selectContainerURLFmt
?
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.
Please refer to the following document:
China: https://docs.microsoft.com/en-us/azure/china/resources-developer-guide
Germany: https://docs.microsoft.com/ca-es/azure////germany/germany-services-storage
US Government: https://docs.microsoft.com/en-us/azure/azure-government/compare-azure-government-global-azure
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'm trying to verify these endpoints, but cannot find authoritative summary documentation. Do you have any relevant link?
Would it make sense to use something like:
var endpoints = map[string]struct{blobURL, containerURL string} { azureGlobal: { blobURL: "https://%s.blob.core.windows.net/%s/%s", containerURL: "https://%s.blob.core.windows.net/%s", }, azureChinaCloud: { blobURL: "https://%s.blob.core.chinacloudapi.cn/%s/%s", containerURL: "https://%s.blob.core.chinacloudapi.cn/%s", }, // ... }and then use the map instead of
selectBlobURLFmt
andselectContainerURLFmt
?
done
Signed-off-by: Binbin <[email protected]>
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.
Thank you!
Signed-off-by: Binbin Zou [email protected]
What this PR does:
support azure storage of AzureChinaCloud,AzureGermanCloud,GerUSGovernment
Which issue(s) this PR fixes:
NONE
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]
Test Images:


