Skip to content

Commit

Permalink
Merge #111286
Browse files Browse the repository at this point in the history
111286: release-22.2: cloud/azure: Fix azure schemes r=benbardin a=benbardin

Backport 1/1 commits from #111217.

/cc `@cockroachdb/release`

---

Part of: https://cockroachlabs.atlassian.net/browse/CRDB-31120

Release note (bug fix): Fixes azure schemes in storage and external conns.

Release justification: bugfix


Co-authored-by: Ben Bardin <bardin@cockroachlabs.com>
  • Loading branch information
craig[bot] and benbardin committed Sep 27, 2023
2 parents 75667a3 + 46acce6 commit 767306c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
3 changes: 2 additions & 1 deletion pkg/ccl/cloudccl/externalconn/datadriven_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ func TestDataDriven(t *testing.T) {
case "inspect-system-table":
rows := tenant.Query(`
SELECT connection_name, connection_type, crdb_internal.pb_to_json('cockroach.cloud.externalconn.connectionpb.ConnectionDetails', connection_details), owner
FROM system.external_connections;
FROM system.external_connections
ORDER BY connection_name;
`)
output, err := sqlutils.RowsToDataDrivenOutput(rows)
require.NoError(t, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,14 @@ exec-sql
CREATE EXTERNAL CONNECTION "foo-azure" AS 'azure-storage://bucket/path?AZURE_ACCOUNT_NAME=foo&AZURE_ACCOUNT_KEY=Zm9vCg==&AZURE_ENVIRONMENT=AzureUSGovernmentCloud'
----

exec-sql
CREATE EXTERNAL CONNECTION "bar-azure" AS 'azure-blob://bucket/path?AZURE_ACCOUNT_NAME=foo&AZURE_ACCOUNT_KEY=Zm9vCg==&AZURE_ENVIRONMENT=AzureUSGovernmentCloud'
----

exec-sql
CREATE EXTERNAL CONNECTION "baz-azure" AS 'azure://bucket/path?AZURE_ACCOUNT_NAME=foo&AZURE_ACCOUNT_KEY=Zm9vCg==&AZURE_ENVIRONMENT=AzureUSGovernmentCloud'
----

# Reject invalid azure external connections.
exec-sql
CREATE EXTERNAL CONNECTION "invalid-param-azure" AS 'azure-storage://bucket/path?INVALIDPARAM=baz'
Expand All @@ -247,12 +255,22 @@ pq: failed to construct External Connection details: failed to create azure exte

inspect-system-table
----
bar-azure STORAGE {"provider": "azure_storage", "simpleUri": {"uri": "azure-blob://bucket/path?AZURE_ACCOUNT_NAME=foo&AZURE_ACCOUNT_KEY=Zm9vCg==&AZURE_ENVIRONMENT=AzureUSGovernmentCloud"}} root
baz-azure STORAGE {"provider": "azure_storage", "simpleUri": {"uri": "azure://bucket/path?AZURE_ACCOUNT_NAME=foo&AZURE_ACCOUNT_KEY=Zm9vCg==&AZURE_ENVIRONMENT=AzureUSGovernmentCloud"}} root
foo-azure STORAGE {"provider": "azure_storage", "simpleUri": {"uri": "azure-storage://bucket/path?AZURE_ACCOUNT_NAME=foo&AZURE_ACCOUNT_KEY=Zm9vCg==&AZURE_ENVIRONMENT=AzureUSGovernmentCloud"}} root

exec-sql
DROP EXTERNAL CONNECTION "foo-azure";
----

exec-sql
DROP EXTERNAL CONNECTION "bar-azure";
----

exec-sql
DROP EXTERNAL CONNECTION "baz-azure";
----

enable-check-external-storage
----

Expand Down
10 changes: 6 additions & 4 deletions pkg/cloud/azure/azure_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ func parseAndValidateAzureConnectionURI(
}

func init() {
externalconn.RegisterConnectionDetailsFromURIFactory(
externalConnectionScheme,
parseAndValidateAzureConnectionURI,
)
for _, s := range []string{scheme, deprecatedScheme, deprecatedExternalConnectionScheme} {
externalconn.RegisterConnectionDetailsFromURIFactory(
s,
parseAndValidateAzureConnectionURI,
)
}
}
8 changes: 5 additions & 3 deletions pkg/cloud/azure/azure_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ const (
// AzureEnvironmentKeyParam is the query parameter for the environment name in an azure URI.
AzureEnvironmentKeyParam = "AZURE_ENVIRONMENT"

scheme = "azure"
externalConnectionScheme = "azure-storage"
scheme = "azure-blob"

deprecatedScheme = "azure"
deprecatedExternalConnectionScheme = "azure-storage"
)

func parseAzureURL(
Expand Down Expand Up @@ -277,5 +279,5 @@ func (s *azureStorage) Close() error {

func init() {
cloud.RegisterExternalStorageProvider(cloudpb.ExternalStorageProvider_azure,
parseAzureURL, makeAzureStorage, cloud.RedactedParams(AzureAccountKeyParam), scheme, externalConnectionScheme)
parseAzureURL, makeAzureStorage, cloud.RedactedParams(AzureAccountKeyParam), scheme, deprecatedScheme, deprecatedExternalConnectionScheme)
}

0 comments on commit 767306c

Please sign in to comment.