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

Fix racing condition using leasing on blob #23

Merged
merged 2 commits into from
Jul 9, 2018
Merged

Conversation

ritazh
Copy link
Member

@ritazh ritazh commented Jul 4, 2018

fixes #22

@ritazh ritazh requested a review from khenidak July 4, 2018 00:01
fmt.Println("Key not found. Creating a new key...")
storageAccountsClient := storagemgmt.NewAccountsClient(subscriptionID)
Copy link
Contributor

Choose a reason for hiding this comment

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

We really don't subscription id here. You can get a token for resource by storage account name, and env (cloud name) only. This way we ask the user for less

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently we are already using subscriptionID to get instance of keyvault to test for its existence. This is being used the same way to test for existence of the storage account.

vaultsClient := kvmgmt.NewVaultsClient(subscriptionID)

Copy link
Member Author

Choose a reason for hiding this comment

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

Also doesnt seem like the Azure Go SDK has the AD authentication feature added for storage yet: https://github.com/Azure/azure-sdk-for-go/blob/v18.0.0/storage/client.go#L269-L276

func NewBasicClient(accountName, accountKey string) (Client, error) {
	if accountName == StorageEmulatorAccountName {
		return NewEmulatorClient()
	}
	return NewClient(accountName, accountKey, DefaultBaseURL, DefaultAPIVersion, defaultUseHTTPS)
}

return nil, err
}
storageAcctName := providerVaultName
res, err := storageAccountsClient.ListKeys(*resourceGroup, storageAcctName)
Copy link
Contributor

Choose a reason for hiding this comment

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

You also don't need that.

@khenidak
Copy link
Contributor

khenidak commented Jul 9, 2018

Shouldn't the configuration file carry the storage account name used for leases?

@ritazh
Copy link
Member Author

ritazh commented Jul 9, 2018

Shouldn't the configuration file carry the storage account name used for leases?

Instead of adding yet another field in the configuration file, I'm using the same name as the keyvault for the storage account.

@khenidak
Copy link
Contributor

khenidak commented Jul 9, 2018

Let us have use AAD auth instead of keys as future feature (issue?) and merge this as is
/lgtm

@ritazh
Copy link
Member Author

ritazh commented Jul 9, 2018

Tracking issue here: #26

@ritazh ritazh merged commit 3387702 into master Jul 9, 2018
@ritazh ritazh deleted the fix-racingcondition branch July 9, 2018 23:38
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.

Racing condition when multiple masters are creating keys at the same time
2 participants