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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing CosmosDB first read region will cause all other read regions be removed #26020

Open
1 task done
leilifremont opened this issue May 18, 2024 · 0 comments
Open
1 task done

Comments

@leilifremont
Copy link

leilifremont commented May 18, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.7.3

AzureRM Provider Version

3.97.1

Affected Resource(s)/Data Source(s)

azurerm_cosmosdb_account

Terraform Configuration Files

resource "azurerm_cosmosdb_account" "db" {
  name                = "test"
  location            = westus3
  resource_group_name = "test"
  offer_type          = "Standard"
  kind                = "MongoDB"

  enable_automatic_failover = true
  enable_multiple_write_locations = false

  capabilities {
    name = "MongoDBv4.2"
  }

  capabilities {
    name = "EnableMongo"
  }

  consistency_policy {
    consistency_level       = "BoundedStaleness"
    max_interval_in_seconds = 300
    max_staleness_prefix    = 100000
  }

  geo_location {
    location          = "westus"
    failover_priority = 0
  }

  geo_location {
    location          = "eastus"
    failover_priority = 1
  }

  geo_location {
    location          = "westus3"
    failover_priority = 2
  }

  geo_location {
    location          = "eastus2"
    failover_priority = 3
  }
}

Debug Output/Panic Output

We're deleting the first read region "eastus" via following change. We have to change the failover_priority of other read regions because "the maximum value for a failover priority = (total number of regions - 1)."

However, this causes all three read regions are removed because "Failover priority values must be unique for each of the regions in which the database account exists. Changing this causes the location to be re-provisioned and cannot be changed for the location with failover priority".

Although eventually the other two read regions will be added back, but this is not we expected. We want the CosmosDB always has more than 2 regions to be highly available. In addition, there are private endpoint changes triggered on Azure end when region was removed and this will cause the application fail to connect to CosmosDB since they use these private endpoints.

This same operation was tried from Azure portal, Azure portal can complete this operation without region removal. Not sure which endpoint Azure use for this, but from the change history, there are no region removal, only the failover priority was changed for all three read regions and at the same time, deleting the first read region as requested.

Terraform should use the same approach or endpoints like Azure portal did for this scenario.

resource "azurerm_cosmosdb_account" "db" {
  name                = "test"
  location            = westus3
  resource_group_name = "test"
  offer_type          = "Standard"
  kind                = "MongoDB"

  enable_automatic_failover = true
  enable_multiple_write_locations = false

  capabilities {
    name = "MongoDBv4.2"
  }

  capabilities {
    name = "EnableMongo"
  }

  consistency_policy {
    consistency_level       = "BoundedStaleness"
    max_interval_in_seconds = 300
    max_staleness_prefix    = 100000
  }

  geo_location {
    location          = "westus"
    failover_priority = 0
  }

  geo_location {
    location          = "westus3"
    failover_priority = 1
  }

  geo_location {
    location          = "eastus2"
    failover_priority = 2
  }
}


### Expected Behaviour

Other read regions won't be removed to ensure high availability. Service shouldn't be interrupted.


### Actual Behaviour

Other read regions would be removed. On Azure end, there are private endpoint changes triggered and this will cause application fail to connect to CosmosDB since they use the private endpoint.

When region removed, service was interrupted, the service use Private endpoints to connect to CosmosDB.



### Steps to Reproduce

_No response_

### Important Factoids

_No response_

### References

_No response_
@github-actions github-actions bot added the v/3.x label May 18, 2024
@leilifremont leilifremont changed the title Remove CosmosDB first read region causing other read region removed Remove CosmosDB first read region causing all other read regions removal May 18, 2024
@leilifremont leilifremont changed the title Remove CosmosDB first read region causing all other read regions removal Removing CosmosDB first read region will cause all other read regions be removed May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants