Skip to content

Commit

Permalink
Allow specifying "Cold" tier (#2096)
Browse files Browse the repository at this point in the history
* Allow specifying "Cold" tier

* Switch service version when setting tier
  • Loading branch information
adreed-msft committed Mar 21, 2023
1 parent 7147b11 commit f3300a8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions common/fe-ste-models.go
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ func (BlockBlobTier) None() BlockBlobTier { return BlockBlobTier(0) }
func (BlockBlobTier) Hot() BlockBlobTier { return BlockBlobTier(1) }
func (BlockBlobTier) Cool() BlockBlobTier { return BlockBlobTier(2) }
func (BlockBlobTier) Archive() BlockBlobTier { return BlockBlobTier(3) }
func (BlockBlobTier) Cold() BlockBlobTier { return BlockBlobTier(4) }

func (bbt BlockBlobTier) String() string {
return enum.StringInt(bbt, reflect.TypeOf(bbt))
Expand Down
13 changes: 13 additions & 0 deletions e2etest/zt_preserve_access_tier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ import (
"testing"
)

//func TestTier_UploadCold(t *testing.T) {
// RunScenarios(t, eOperation.Copy(), eTestFromTo.Other(common.EFromTo.LocalBlob()), eValidate.Auto(), anonymousAuthOnly, anonymousAuthOnly, params{
// recursive: true,
// accessTier: common.EBlockBlobTier.Cold().ToAccessTierType(), // this is not valid yet on the service, so this test is disabled.
// }, nil, testFiles{
// defaultSize: "4M",
// shouldTransfer: []interface{}{
// folder(""), // root folder
// f("filea"),
// },
// }, EAccountType.Classic(), EAccountType.Standard(), "")
//}

func TestTier_V2ToClassicAccount(t *testing.T) {

RunScenarios(t, eOperation.Copy(), eTestFromTo.Other(common.EFromTo.BlobBlob()), eValidate.AutoPlusContent(), anonymousAuthOnly, anonymousAuthOnly, params{
Expand Down
11 changes: 11 additions & 0 deletions ste/mgr-JobPartMgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@ func NewBlobPipeline(c azblob.Credential, o azblob.PipelineOptions, r XferRetryO
pipeline.MethodFactoryMarker(), // indicates at what stage in the pipeline the method factory is invoked
// NewPacerPolicyFactory(p),
NewVersionPolicyFactory(),
// Bump the service version when using the Cold access tier.
pipeline.FactoryFunc(func(next pipeline.Policy, po *pipeline.PolicyOptions) pipeline.PolicyFunc {
// TODO: Remove me when bumping the service version is no longer relevant.
return func(ctx context.Context, request pipeline.Request) (pipeline.Response, error) {
if request.Header.Get("x-ms-access-tier") == common.EBlockBlobTier.Cold().String() {
request.Header.Set("x-ms-version", "2021-12-02")
}

return next.Do(ctx, request)
}
}),
NewRequestLogPolicyFactory(RequestLogOptions{
LogWarningIfTryOverThreshold: o.RequestLog.LogWarningIfTryOverThreshold,
SyslogDisabled: common.IsForceLoggingDisabled(),
Expand Down
2 changes: 1 addition & 1 deletion ste/xfer-anyToRemote-file.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func BlobTierAllowed(destTier azblob.AccessTierType) bool {
// Standard storage account. If it's Hot, Cool, or Archive, we're A-OK.
// Page blobs, however, don't have an access tier on Standard accounts.
// However, this is also OK, because the pageblob sender code prevents us from using a standard access tier type.
return destTier == azblob.AccessTierArchive || destTier == azblob.AccessTierCool || destTier == azblob.AccessTierHot
return destTier == azblob.AccessTierArchive || destTier == azblob.AccessTierCool || destTier == common.EBlockBlobTier.Cold().ToAccessTierType() || destTier == azblob.AccessTierHot
}
}

Expand Down

0 comments on commit f3300a8

Please sign in to comment.