-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
[WIP] Separate plan and apply for output values #21762
Conversation
f73c825
to
4214ef8
Compare
This is a variant of Remove which adds new edges to ensure that everything that was depending on the removed node for ordering will retain the same relative ordering even after the node is removed.
4214ef8
to
6198e9a
Compare
This PR started off as trying to fix #21662, but it turned out that it wasn't really a 0.12 regression as such, but rather just that the ability to now depend on an entire module at once makes it easier to run into a limitation that already existed in prior versions: named values (local values, output values, input variables) represented as graph nodes don't play well in the destroy graph. The test locals {
value = "local"
foo_id = aws_instance.foo.id
// baz is not in the state during destroy, but this is a valid config that
// should not fail.
baz_id = aws_instance.baz.id
}
resource "aws_instance" "baz" {}
resource "aws_instance" "foo" {
provisioner "shell" {
id = self.id
command = local.value
when = "destroy"
}
}
resource "aws_instance" "bar" {
provisioner "shell" {
id = self.id
command = local.foo_id
when = "destroy"
}
} With the code from this branch (which already includes changes intended to work towards fixing #21662, and is thus slightly different behavior than current The reason for this cycle is that the
The fact that this process both starts end ends with evaluating Having traced all that through, this then looks a lot like the problem in #11716: that one is discussing a different variant of this problem involving output values. That one didn't create a cycle because That brings me back to the idea I was considering in that other issue: it's feeling to me like named values shouldn't be nodes in the main graph at all, but rather should be re-evaluated immediately after any change to something they refer to. In #11716 (when I was focused only on outputs) I was thinking about a brute-force approach of just re-evaluating all the outputs after any resource change as a simple initial fix. However, once we understand the problem to actually include all named values (local values, output values, and input variables) that is no longer sufficient: these objects can have references to each other, so they do need to be in a graph, even if that isn't the main one. I think my next step for this investigation, then, would be to prototype something like the following:
In effect, this separates the operations that have side effects from the values derived from them so that the same object can have multiple side-effects applied to it during the main walk and yet we can keep the derived values in sync after each step. I have exhausted all the time I have for this right now since I'm about to be on vacation for a while; the above is mostly just an aid to reloading all this context again when I'm next able to spend time on this. |
We have a lot of difficulties with cycle errors when using "terraform destroy" I 'm a bit worried about the second dependencies graph you are about to build I don' t fully understand it but allow me to explain a pattern we are often using so you can check if it works in the new setup. We use it to express that a module is dependent of some other resources. When we call a module we use the role_depends_on attribute to provide a list of resources
In the module we create a null resoure that is referencing all of these resources
and we use this in the depends_on attribute of other resources in that module
|
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. |
No description provided.