libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [libcloud] mkcello96 opened a new issue #1551: Azure blobs - empty string `key` workaround does not work
Date Thu, 28 Jan 2021 19:01:50 GMT

mkcello96 opened a new issue #1551:
URL: https://github.com/apache/libcloud/issues/1551


   ## Summary
   
   I'm using libcloud to connect to Azure Gov, so I need to change `host` in my AzureBlobsStorageDriver
connection object (which uses `<account>.blob.core.usgovcloudapi.net` instead of the
default `<account>.blob.core.windows.net`). This does not work - the call fails with
`Unexpected status code: 400`.
   
   This broke after https://issues.apache.org/jira/browse/LIBCLOUD-1033 was merged ~2 years
ago.
   
   ## Detailed Information
   
   https://issues.apache.org/jira/browse/LIBCLOUD-1033 adds support for Azurite, which largely
assumes libcloud users would be setting `host` only if using an Azure emulator. Thus, it will
always set an `account_prefix`=`key` IFF a `host` is specified, which will break non-emulated
Azure calls ([see how a list containers call has a separate Request URI for Emulated calls](https://docs.microsoft.com/en-us/rest/api/storageservices/list-containers2)).

   A workaround for those not using emulators was proposed [here](https://github.com/apache/libcloud/blame/fe4f81b5a31a8f470ff6ba5af7451cccfc423c2b/libcloud/storage/drivers/azure_blobs.py#L167),
to set the key to '' (empty string). **This workaround also does not work** - the call also
fails with `Unexpected status code: 400`.
   
   After a lengthy debugging session I figured out why the proposed workaround does not work:
Setting `key` to the empty string does not prevent `account_prefix` from being set (it also
gets set to the empty string). Further, doing this adds an extra `/` to the Request URI ([code
here](https://github.com/apache/libcloud/blame/fe4f81b5a31a8f470ff6ba5af7451cccfc423c2b/libcloud/storage/drivers/azure_blobs.py#L193)),
which will cause the Azure request to fail. Setting `key=None` fixes this issue.
   However that is not the only issue with the proposed workaround - not having a `key` also
prevents Azure authentication from working. Therefore I had to add a `driver.connection.user_id
= key_variable` statement after the AzureBlobsStorageDriver object was initialized to fix
this.
   
   TL;DR - my current workaround is to do this:
   ```
   AzureBlobsStorageDriver(key=None, secret=<secret>, host=<storageAccount>.blob.core.usgovcloudapi.net
)
   driver.connection.user_id = <storageAccount>
   ```
   
   My fix recommendation is that an `emulated` boolean flag parameter be added to the AzureBlobsStorageDriver
initializer, which will only set the `account_prefix` if it's True. This should also allow
the `key` parameter to be set with the `host`.
   
   OS: Mac OS
   Python version: 3.6.8
   Libcloud version: 3.3.1
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message