X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/3cbe55d440788b0b9b1a9d9e642103929b57e8fd..e76a00ca471102d1e536737073314e0f36cf086a:/services/keepstore/azure_blob_volume.go diff --git a/services/keepstore/azure_blob_volume.go b/services/keepstore/azure_blob_volume.go index 220744c25c..c64ac7a8fe 100644 --- a/services/keepstore/azure_blob_volume.go +++ b/services/keepstore/azure_blob_volume.go @@ -1,3 +1,7 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + package main import ( @@ -97,6 +101,7 @@ func init() { type AzureBlobVolume struct { StorageAccountName string StorageAccountKeyFile string + StorageBaseURL string // "" means default, "core.windows.net" ContainerName string AzureReplication int ReadOnly bool @@ -116,6 +121,14 @@ func (*AzureBlobVolume) Examples() []Volume { AzureReplication: 3, RequestTimeout: azureDefaultRequestTimeout, }, + &AzureBlobVolume{ + StorageAccountName: "cn-account-name", + StorageAccountKeyFile: "/etc/azure_cn_storage_account_key.txt", + StorageBaseURL: "core.chinacloudapi.cn", + ContainerName: "cn-container-name", + AzureReplication: 3, + RequestTimeout: azureDefaultRequestTimeout, + }, } } @@ -136,7 +149,10 @@ func (v *AzureBlobVolume) Start() error { if err != nil { return err } - v.azClient, err = storage.NewBasicClient(v.StorageAccountName, accountKey) + if v.StorageBaseURL == "" { + v.StorageBaseURL = storage.DefaultBaseURL + } + v.azClient, err = storage.NewClient(v.StorageAccountName, accountKey, v.StorageBaseURL, storage.DefaultAPIVersion, true) if err != nil { return fmt.Errorf("creating Azure storage client: %s", err) } @@ -162,6 +178,11 @@ func (v *AzureBlobVolume) Start() error { return nil } +// DeviceID returns a globally unique ID for the storage container. +func (v *AzureBlobVolume) DeviceID() string { + return "azure://" + v.StorageBaseURL + "/" + v.StorageAccountName + "/" + v.ContainerName +} + // Return true if expires_at metadata attribute is found on the block func (v *AzureBlobVolume) checkTrashed(loc string) (bool, map[string]string, error) { metadata, err := v.bsClient.GetBlobMetadata(v.ContainerName, loc) @@ -634,13 +655,15 @@ func (v *AzureBlobVolume) InternalStats() interface{} { type azureBlobStats struct { statsTicker - Ops uint64 - GetOps uint64 - GetRangeOps uint64 - CreateOps uint64 - SetMetadataOps uint64 - DelOps uint64 - ListOps uint64 + Ops uint64 + GetOps uint64 + GetRangeOps uint64 + GetMetadataOps uint64 + GetPropertiesOps uint64 + CreateOps uint64 + SetMetadataOps uint64 + DelOps uint64 + ListOps uint64 } func (s *azureBlobStats) TickErr(err error) { @@ -670,14 +693,14 @@ func (c *azureBlobClient) ContainerExists(cname string) (bool, error) { } func (c *azureBlobClient) GetBlobMetadata(cname, bname string) (map[string]string, error) { - c.stats.Tick(&c.stats.Ops) + c.stats.Tick(&c.stats.Ops, &c.stats.GetMetadataOps) m, err := c.client.GetBlobMetadata(cname, bname) c.stats.TickErr(err) return m, err } func (c *azureBlobClient) GetBlobProperties(cname, bname string) (*storage.BlobProperties, error) { - c.stats.Tick(&c.stats.Ops) + c.stats.Tick(&c.stats.Ops, &c.stats.GetPropertiesOps) p, err := c.client.GetBlobProperties(cname, bname) c.stats.TickErr(err) return p, err