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

Add thread safe public set_storage_credentials to cloud_client #353

Merged
merged 6 commits into from
Jun 24, 2020

Conversation

will-tong
Copy link
Contributor

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

Copy link

@scharan scharan left a 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.

Copy link
Member

@Jinming-Hu Jinming-Hu left a 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.

@will-tong
Copy link
Contributor Author

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 throw azure::storage::storage_exception(reason, true /*retryable*/); so that the wasstorage retry mechanism will do the trick.

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.

@will-tong
Copy link
Contributor Author

will-tong commented Jun 11, 2020

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.

@Jinming-Hu
Copy link
Member

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.

@Jinming-Hu
Copy link
Member

/azp run

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

Copy link
Member

@Jinming-Hu Jinming-Hu left a 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.

@Jinming-Hu
Copy link
Member

@will-tong Can you please rebase this PR on top of dev branch to get CI passed?

@will-tong
Copy link
Contributor Author

will-tong commented Jun 15, 2020

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.

@Jinming-Hu
Copy link
Member

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 account_key() if it's empty.

@Jinming-Hu
Copy link
Member

/azp run

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@Jinming-Hu
Copy link
Member

Seems there's a test case failed. I'll look into it when i'm available.

@Jinming-Hu
Copy link
Member

@will-tong The way you rebased is wrong. My commit is listed in this PR. This will lead to conflicts when merging.

@will-tong
Copy link
Contributor Author

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.

@Jinming-Hu
Copy link
Member

/azp run

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 353 in repo Azure/azure-storage-cpp

@Jinming-Hu
Copy link
Member

/azp run

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@vinjiang vinjiang merged commit efbf424 into Azure:dev Jun 24, 2020
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.

5 participants