-
Notifications
You must be signed in to change notification settings - Fork 92
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
A plan with multiple elasticsearch.topology
blocks is not idempotent
#336
Comments
The issue start happens when you have three or more nodes
|
@kuisathaverat sorry for the late reply here, I was on PTO and had a couple of high priority things to work on this week, I'll take a look at this bug as soon as I can. |
no rush, we have to workaround it with the autoscale setting, so we do not touch the infra ever only the Elastic Stack version or other settings. |
@kuisathaverat I found what had been happening for you, let me try and explain it to the best of my ability. Like I explained through Slack, I believe that what you're seeing is due to the topology elements not being specified in alphabetical order, which is a current limitation of the provider, since we’re using the schema.TypeList for the elasticsearch.topology block, more details below. There’s a few caveats to the way that we define our topology elements to be able to work around a few limitations of the current Terraform SDK, but since we’re using the deployment templates as the initial configuration, then allowing users to override certain fields on top of that configuration, we have a lot of “computed” and “optional” fields in the schema, since the value can either be calculated by what the API returns, or what the user directly specifies. Computed and optional fields are great to accommodate the flexibility that our system exposes, but they have some problems, for example, they do not play well when they are nested within a schema.TypeSet, which the type that we would need to use for the elasticsearch.topology block. Computed and optional fields have many more problems than what was just described and are inherently flawed due to the fact that the Terraform framework is unable to reconcile where the value came from. Terraform has no way to know where the value that is desired came from (state persistence or user input), which has to do with the way that it reconciles and generates the current and saved state. There are a few open issues that describe and dig deep into this behavior (hashicorp/terraform#29028, hashicorp/terraform-plugin-sdk#413, hashicorp/terraform-plugin-sdk#261), and have prompted Hashicorp and the Terraform maintainer team to start a new Terraform framework project (https://github.com/hashicorp/terraform-plugin-framework) that aims to solve some of these problems if not all of them, however, the project is still in its infancy and cannot be used for a project that is already public and that our customers are already using. Wrapping up, this has a few implications for us:
|
elasticsearch.topology
blocks is not idempotent
I found a case that even so you pass the
|
Hi @marclop I have a similar issue, still related to the use of schema.TypeList for the elasticsearch.topology block as far as I can tell. When modifying a topology by adding for instance a master this generates an error if the topologies are in alphabetical order. As an example, updating this topology:
to:
fails with the following error:
The only way I've found to make this work is to apply this topology:
where master is now at the end of the list, after all the existing entries. However after applying this successfully, I end up having the issue mentioned in the previous comments and if I run terraform plan I get a new plan to shift my toplogies around:
so to fix this, I have to shift my topology entries back into the right alphabetical order and that will now give me the clean empty plan that I expect.
Which is not the best user experience unfortunately. Also would this really work when scaling down topologies, as removing entries might cause other issues? I understand from all the comments above that schema.TypeSet is not an option because of all the limitations that come with it, but what about instead using schema.TypeMap with the topology id as key? Do you think that could work? Apologies if this is not quite the same issue as the one described in the previous comments, it's somewhere between this and issue 415. I have posted it here as the cause of all of them is the same as you have explained very clearly in your comments. If you want I can create a separate issue with all this. |
I think the safest way is to always specify all topology elements in alphabetical order and setting the ones that are not required to This requires a code change though: It works reliably for me after removing these lines that remove empty topology elements from state: Edit: This solves some, but not all issues. This plugin needs to be ported to Terraform Plugin Framework so this can be completely fixed. |
Is it expected behavior that Example:
|
The provider omits topology elements with zero size when it reads state from backend. However configuration can specify a tier with zero size. It will lead to the tier deletion. The "more intuitive" approach with omitting deleted tier cannot be used - the provider uses |
Thanks for your reply but I'm afraid I still don't clearly understand if what I am observing is expected or not. I have configuration that specifies multiple topologies, e.g.
When I run
That is not expected by me. I don't have any Could you help me understand if what I am observing is expected or not? Will |
TL;DR - it's expected. When 'terraform plan The provider uses As a rule of thumb, it makes sense to omit empty (zero sized) topology elements if autoscaling is disabled. Then, once you need to delete a tier, you can set its size to zero and after successful We hope to fix the behavior with the move to Terraform Plugin Framework. |
I just stumbled on this as well with 0.4.1 and it's a big blocker to use the provider, both for testing purposes and production use.
I guess EDIT: actually The schema reference could be |
It looks like |
Closed by #567 |
After executing a terraform plan successfully, if you apply the same plan it failed with an error related to node types id not present.
Note: the use case is to update the plan before apply again but it fails in the basic case of no changes in the plan.
Note: A plan with only hot_content nodes does not fail.
Readiness Checklist
Expected Behavior
The second execution of terraform apply should not fail, and apply no changes.
Current Behavior
The second execution of terraform failed with the following error:
## Terraform definitionm
Steps to Reproduce
main.tf
terraform init
terraform apply -auto-approve=true
terraform apply -auto-approve=true
againContext
We plan to make daily updates over the plan, the current version failed in case you have changes in the plan and in case you do not have changes. This makes not possible to migrate to terraform-provider-ec from the current tool we use (ecl).
Possible Solution
Your Environment
The text was updated successfully, but these errors were encountered: