-
Notifications
You must be signed in to change notification settings - Fork 23
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
TERRA-79 ⁃ Database region order leads to configuration drift #170
Comments
@giannoul What version of the provider are you using? I just tried this with v2.1.4 (should also work with 2.1.5) and while it is a pain to have to re-order the regions list in your terrafrom config file, it does seem to work. I followed your steps and di not have an issue with |
@emerkle826 I have created another database to provide more concrete data on the above variable values:
From this point onwards, all Terraform apply/plan will result to the message:
In order to verify that the order is wrong I did add one more region, the However using the value
As you can see the order is lexicographic or it comes from this endpoint:
but always lead to drift in Terraform. |
The version of the |
@emerkle826 Hey Erik, I see that you responded to this query, so I don't know if you're working on it, but can you update this? |
@giannoul @StevenLacerda Sorry I haven't responded sooner. I've been swamped with other work and haven't had a chance to get to this. I am trying to shuffle things so I can bring some much needed attention back to the provider soon. |
@emerkle826 Did you have any chance to look into this? |
@emerkle826 kind reminder |
@gtseres Sorry again for the delay. I am revisiting this now. |
@giannoul @gtseres I think I have a solution for this, but it may come at a cost. The problem with the current implementation is that the list of regions is treated as an ordered list inside the Terraform SDK. Anything I do to try to ignore the ordering can't be applied before Terraform detects a change. So once the order doesn't match exactly, any Switching to a set, however, means that we lose the special handling of the first element in the regions list being interpreted as the primary datacenter region. If I change the regions array to a set internally, I will have to separate the primary region from the additional regions in order to not lose track of the primary region, which will require a change to your current In addition to a definition change, switching the additional regions from an ordered list to an unordered set means that adding datacenetrs in other regions will not necessarily be done in the order they are listed in your definition. So if controling which region DC-2 is deployed to matters, this change would just create new problems. I would appreciate your input about this change. As an example, this is how a definition would look for multi-datacenters going forward: resource astra_database "terra79" {
name = "terra79"
keyspace = "testks"
cloud_provider = "gcp"
region = "us-west4"
additional_regions = ["us-east1", "us-east4", "us-central1"]
timeouts {
create = "45m"
update = "45m"
delete = "45m"
}
deletion_protection = false
} And here is how that database would be represented in the state file: resource "astra_database" "terra79" {
additional_keyspaces = []
additional_regions = [
"us-central1",
"us-east1",
"us-east4",
]
cloud_provider = "GCP"
cqlsh_url = "https://d0b415b7-41d9-4edd-bb68-2d3283d87874-us-west4.apps.astra.datastax.com/cqlsh"
data_endpoint_url = "https://d0b415b7-41d9-4edd-bb68-2d3283d87874-us-west4.apps.astra.datastax.com/api/rest"
datacenters = {
"GCP.us-central1" = "d0b415b7-41d9-4edd-bb68-2d3283d87874-5"
"GCP.us-east1" = "d0b415b7-41d9-4edd-bb68-2d3283d87874-3"
"GCP.us-east4" = "d0b415b7-41d9-4edd-bb68-2d3283d87874-4"
"GCP.us-west4" = "d0b415b7-41d9-4edd-bb68-2d3283d87874-1"
}
deletion_protection = false
grafana_url = "https://d0b415b7-41d9-4edd-bb68-2d3283d87874-us-west4.dashboard.astra.datastax.com/d/cloud/dse-cluster-condensed?refresh=30s&orgId=1&kiosk=tv"
graphql_url = "https://d0b415b7-41d9-4edd-bb68-2d3283d87874-us-west4.apps.astra.datastax.com/api/graphql"
id = "d0b415b7-41d9-4edd-bb68-2d3283d87874"
keyspace = "testks"
name = "terra79"
node_count = 12
organization_id = <edited for security>
owner_id = <edited for security>
region = "us-west4"
replication_factor = 1
status = "ACTIVE"
total_storage = 5
timeouts {
create = "45m"
delete = "45m"
update = "45m"
}
} Notice that the order of To sum up, I would appreciate your opinions on this change. In order for the plugin to not detect a change in the set of additional datacenters/regions, you would have to give up deterministic ordering when adding datacenters/regions. If the order in which DCs are added is not important, then I think this change would solve this issue (and be a better design). |
Hello @emerkle826 We are using the |
@giannoul Thank you for the response. I'm finishing up the work in #217. I think that when I release it, I will bump the version from 2.1.X to 2.2.x as it will change how astra_database resources and datasources are defined. I will try to write up a little bit in the README how to handle upgrading it when released..... |
Did you already try doing a |
Still happens on 2.1.17 even with |
Terraform Version
Affected Resource(s)
Please list the resources as a list, for example:
Terraform Configuration Files
which is fed with variable values:
Debug Output
None
Panic Output
None
Expected Behavior
After
terraform apply
we should not be asked for the following change in subsequent applies:Actual Behavior
On every
apply
orplan
we are notified about the regions change.Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
["us-central1", "us-east4", "us-west4"]
["us-central1", "us-west4"]
["us-central1", "us-west4", "us-east4"]
["us-central1", "us-west4", "us-east4"]
Important Factoids
No
References
No
┆Issue is synchronized with this Jira Task by Unito
┆friendlyId: TERRA-79
┆priority: Major
The text was updated successfully, but these errors were encountered: