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

Respect common HTTP headers when uploading Azure Storage blob via stream #1553

Merged
merged 3 commits into from Feb 15, 2021

Conversation

c-w
Copy link
Member

@c-w c-w commented Feb 8, 2021

Respect common HTTP headers when uploading Azure Storage blob via stream

Description

Resolves #1550

As per the documentation, when uploading an object via stream to Azure Storage, common HTTP headers (e.g. Content-Encoding) must be provided via an Azure-specific name (e.g. x-ms-blob-content-encoding). The driver was previously ignoring user-provided headers when uploading objects via stream and wasn't adapting the header names to their Azure-specific equivalent, which are both issues fixed by this pull request.

Status

  • done, ready for review

Checklist (tick everything that applies)

@@ -929,6 +932,31 @@ def delete_object(self, obj):

return False

def _fix_headers(self, headers):
Copy link
Member

Choose a reason for hiding this comment

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

Can you please add some unit tests for this method / functionality?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fitting this into the mock request/response framework was proving challenging so I added an isolated test for the new normalization functionality in 98cd383. I also added an integration test for this scenario in c-w/libcloud-tests@e305b9d.

Copy link
Member Author

Choose a reason for hiding this comment

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

Investigating why the new e2e test fails for Azurite v3 only (see test run).

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, direct unit tests for that method are fine :)

Maybe something to do with auth signature? Since, IIRC, we use header values when generating the signature.

Copy link
Member

Choose a reason for hiding this comment

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

On that note - I wonder if we could some merge some of that end to end tests in that repo (if it makes sense and how we could do that).

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe the test failure may be linked to an issue in AzuriteV3, see Azure/Azurite#629 (comment). Given that the test passes for all other storage targets, I disabled the test for AzuriteV3 in c-w/libcloud-tests@b2be083.

Copy link
Member

@Kami Kami left a comment

Choose a reason for hiding this comment

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

LGTM, just some unit tests would be good (I assume libcloud-tests covers the integration / end to end part) :)

@c-w c-w merged commit 55fb3bc into trunk Feb 15, 2021
@c-w c-w deleted the storage-azureblobs-fix-1550-contentencoding branch February 15, 2021 15:19
d-mo pushed a commit to mistio/libcloud that referenced this pull request Nov 15, 2021
…eam (apache#1553)

* Respect headers uploading Azure blob via stream

* Add tests for _fix_headers
d-mo pushed a commit to mistio/libcloud that referenced this pull request Nov 19, 2021
…eam (apache#1553)

* Respect headers uploading Azure blob via stream

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

Successfully merging this pull request may close these issues.

Azure Blob Storage does not return Content-Encoding when blob was uploaded via stream
2 participants