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

azurerm_cosmosdb_mongo_collection: ignore throughput if Cosmos DB provisioned in 'serverless' capacity mode #10389

Merged
merged 3 commits into from
Mar 3, 2021

Conversation

wiebeck
Copy link
Contributor

@wiebeck wiebeck commented Jan 30, 2021

This should fix #9697. I stumbled upon the same "Error reading Throughput on Cosmos Mongo Collection" when I provisioned a "serverless" Cosmos DB in Mongo mode.

There was already some code in other places (obviously missing from cosmosdb_mongo_collection_resource.go) that handles throughput if and only if...

  1. ...the database account contains any Capabilities
  2. ...these Capabilities do not contain EnableServerless

However I think that throughput should also be handled if there are no Capabilities since "Provisioned throughput" is the default, so I fixed that as well.

I moved the code into a central function isServerlessCapacityMode (DRY!) which I put into file cosmosdb_account_resource.go. Not sure if this is the right place though.

Feedback very welcome!

Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

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

Hey @wiebeck, thanks for taking the time to write this PR! I just have a minor comment for an extra anil check and a request to add serverless tests to each of the resources you've touched. I believe a couple already have tests for serverless so we just have to make sure the others have them too

func isServerlessCapacityMode(accResp documentdb.DatabaseAccountGetResults) bool {
if props := accResp.DatabaseAccountGetProperties; props != nil && props.Capabilities != nil {
for _, v := range *props.Capabilities {
if *v.Name == "EnableServerless" {
Copy link
Member

Choose a reason for hiding this comment

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

We should confirm that v isn't nil before pointing to it

@ghost ghost added size/L and removed size/M labels Mar 2, 2021
Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

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

LGTM!

@mbfrahry mbfrahry changed the title Cosmos DB: ignore throughput if Cosmos DB provisioned in 'serverless' capacity mode azurerm_cosmosdb_mongo_collection: ignore throughput if Cosmos DB provisioned in 'serverless' capacity mode Mar 3, 2021
@mbfrahry mbfrahry merged commit fde3ef4 into hashicorp:master Mar 3, 2021
mbfrahry added a commit that referenced this pull request Mar 3, 2021
@ghost
Copy link

ghost commented Apr 2, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Apr 2, 2021
@wiebeck wiebeck deleted the serverless_mongo_collection branch April 6, 2021 06:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error reading Throughput on Cosmos Mongo Collection for Serverless CosmosDb
2 participants