-
Notifications
You must be signed in to change notification settings - Fork 148
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
Add thread safe public set_storage_credentials to cloud_client #353
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm from client interface perspective; please get it reviewed by the SDK team.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not thread safe.
In the first place, why do you want to change the credential? Do you want to refresh the bearer token? If so, it shouldn't be done in this way.
We have a service that talks to BlobStore using wasstorage.dll. Following some initial checks, the service creates a storage client object and setup a bunch of parameters on this client object, which we then use to talk to wasstorage. When creating the client, we use account keys. The case we are specifically trying to address here is the scenario when the key is rotated. We rely on the retry mechanism etc., that are built into the wasstorage library, so this is an attempt to reuse the same client and switch its credentials and Adding retries at the top level would be expensive in terms of new code and is wasteful to throw away a fully setup client. The capability to switch the client credentials would simplify the service code. |
Jinming suggested adding a setter to account_key inside service_credential, instead of recreating service_credential with a new account key. As such, I used a shared pointer similar to the existing bearer token credentials that allow for a threadsafe update. |
@will-tong Thank you very much for your contribution, we'll take some time to review it. |
/azp run |
No pipelines are associated with this pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
request some small changes, see comments.
@will-tong Can you please rebase this PR on top of dev branch to get CI passed? |
Changes were made. Note that method is_account_key() is a breaking change in this instance since empty() is no longer valid on an account_key, this is seen in the cloud_storage_account_test file change. |
I think this is fine. people aren't supposed to call |
/azp run |
No pipelines are associated with this pull request. |
Seems there's a test case failed. I'll look into it when i'm available. |
@will-tong The way you rebased is wrong. My commit is listed in this PR. This will lead to conflicts when merging. |
Sorry for the rebasing issue, I ended up just doing a force push from my forked dev to forked master with the proper commits, so things seem to be properly mergeable now. |
/azp run |
No pipelines are associated with this pull request. |
Commenter does not have sufficient privileges for PR 353 in repo Azure/azure-storage-cpp |
/azp run |
No pipelines are associated with this pull request. |
This is useful/needed to swap between primary and secondary shared access keys without recreating the client, in conjunction with retries and retry handling in azure::storage::operation_context::set_response_received. Currently, access key expiry during operation would result in need to recreate client.
Adding thread safety on top of PR #303