-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Incorrect order of execution when deleting resource that participates in dependency, together with the dependency #18408
Comments
I believe this is similar or the same issue as #8617. I have also run into exactly this problem. My understanding is that it is not that terraform is doing things in the reverse order to what we expect, it is that it is trying to complete the update and the delete in parallel. |
Hi @annakhm! Sorry for this weird behavior, and thanks for reporting it. This does indeed seem to be similar to #8617. However, that issue is covering a number of different situations (running The intended behavior for Terraform is that it should record in the state file the dependencies that were present in the configuration when each resource instance is created. This information should then be used when dealing with resources that have been removed from configuration altogether, since without the configuration block there is no record of those dependencies left in the configuration. From the reproduction steps here (which I'm afraid I haven't been able to run myself yet, since I don't have an Whether these values are recorded correctly in the state will help to figure out if the problem is in the construction of the state record itself or if it's in the interpretation of those records. Thanks, and sorry again for this confusing behavior. |
Hi @apparentlymart, thanks for your response! The state file looks correct to me: "nsxt_lb_pool.test": { Here is the full state file https://gist.github.com/annakhm/878961392356014df339cb8fcf9ed3c1 |
Thanks for sharing those, @annakhm! In our feature branch for the next major release we've slightly reworked how However, it would still be nice to understand better what's going on here. From what you reported here it sounds like something isn't working quite right in the graph building phase, causing Terraform to "miss" those edges when it builds the graph to apply the plan. If that is true, we may be able to see (or not see, rather) the missing edges in the
The final command above should produce a graphviz representation of the dependency graph for applying the given plan, which is supposed to have dependency edges reflecting the |
Hi, the graph output is below:
|
Thanks! Here's the rendered graph: Indeed it does seem like there's an edge missing between the two resources here, so at least we have an explanation for the behavior. We don't yet have a cause, but since (as I mentioned before) we have a reworked version of the graph builder in our development branch let's wait until that is in a more usable state and we can give this a try there to see what remains to be fixed there, if anything. Thanks again for all the debugging help here! Once we're ready to test this in both 0.11 and the 0.12 development branch we'll see if we can reproduce this with the |
Thanks @apparentlymart! |
@annakhm Did you generate that graph manually, or programmatically? If the latter, please share your method 👍 I'm dying to visualize terraform dependency trees |
@sloan-dog "terraform graph" generates the graph in dot format |
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
I feel like this is a very basic issue, but couldn't find similar existing issues. I think this is different that life cycle management of specific resource.
In the configuration sample below, if we remove both passive monitor and passive_monitor_id line from nsxt_lb_pool resource, terraform will first delete the passive monitor resource, and then update the dependency. This fails in provider, since on backend the monitor is being used in pool resource.
Terraform Version
Terraform Configuration Files
Expected Behavior
Since terraform is aware of the dependency, I would expect lb_pool to be updated first, and then passive monitor resource to be deleted.
Actual Behavior
Passive monitor is deleted, and then lb_pool is updated.
Steps to Reproduce
The text was updated successfully, but these errors were encountered: