Skip to content
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

Added accessTier check to download call for BlobHandler.ts to fail on… #2483

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

BrendonK
Copy link

… archived blobs.

#2473

Thanks for contribution! Please go through following checklist before sending PR.

PR Branch Destination

  • For Azurite V3, please send PR to main branch.
  • For legacy Azurite V2, please send PR to legacy-dev branch.

Always Add Test Cases

Make sure test cases are added to cover the code change.

Add Change Log

Add change log for the code change in Upcoming Release section in ChangeLog.md.

Development Guideline

Please go to CONTRIBUTION.md for steps about setting up development environment and recommended Visual Studio Code extensions.

@BrendonK
Copy link
Author

@microsoft-github-policy-service agree

@@ -80,6 +80,10 @@ export default class BlobHandler extends BaseHandler implements IBlobHandler {
options.modifiedAccessConditions
);

if (blob.properties.accessTier === Models.AccessTier.Archive) {
throw StorageErrorFactory.getBlobArchived(context.contextId!);
Copy link
Member

@blueww blueww Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please confirm the error returned here is same as the error return from product Azure server. (status code, error code, error message.)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blueww I got the error codes/message from here so it should be okay I think:
BlobArchived Conflict (409) This operation is not permitted on an archived blob.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blueww some tests are failing - I will check the failures to see what's causing it.

brendonkpss and others added 2 commits October 28, 2024 17:45
Updated sas.test.ts test to handle new error.detail.code for Archived…
@@ -253,6 +253,22 @@ describe("BlobAPIs", () => {
assert.fail();
});

it("download should not work when blob in Archive tier", async () => {
Copy link
Member

@blueww blueww Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add @loki @sql as other test cases, to indicate the case can run on both loki and sql.

@@ -2122,7 +2122,7 @@ describe("Shared Access Signature (SAS) authentication", () => {
}
assert.ok(error !== undefined);
assert.equal(error.statusCode, 409);
assert.equal(error.details.code, "BlobArchived");
assert.equal(error.details.code, "CannotVerifyCopySource");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SQL test case failure on this, looks related with sourceBlob.setAccessTier("Archive"); on line 2113 don't have await, it's async call, without await the access tier might still not convert to archive.

Add await should can resolve the failure.
await sourceBlob.setAccessTier("Archive");

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have fixed the case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants