-
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
fix CreateBeforeDestroy with datasources #9853
Conversation
132a1bc
to
fafe737
Compare
The graph transformation we implement around create_before_destroy need to re-order all resources that depend on the create_before_destroy resource. Up until now, we've requires that users mark all of these resources as create_before_destroy. Data soruces however don't have a lifecycle block for create_before_destroy, and could not be marked this way. This PR checks each DestroyNode that doesn't implement CreateBeforeDestroy for any ancestors that do implement CreateBeforeDestroy. If there are any, we inherit the behavior and re-order the graph as such.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great.
One thing that is really critical with stuff like this is that we always pair it with a context test (apply, plan, etc. whatever it affects). This will allow us to move to new graphs more safely, which we do have planned. :)
Can you add a test to context_plan_test.go
? I think this was affecting plan you said.
fafe737
to
cf3a259
Compare
This test will fail with a cycle before we check ancestors for CreateBeforeDestroy.
Awesome to see this fixed! 😀 It looks like this would also address managed resources that depend on CBS resources, right? There is at least one issue out there for the cycles that causes, and some warnings about it in the docs for CBS. |
Yes, I think this should fix many (most, all??!) issues around cycles created from CBD resources. If this does work generally, we won't need the extra documentation and warnings about setting CBD for all dependent resources when you use it in a config, as TF should now properly re-order the the entire dependent destroy sequence. I think there's probably a more precise way to do this after the CreateBeforeDestroy transform, by analyzing the subgraph cycles and only re-ordering the minimal set necessary, but this seems like a good first step and a more precise ordering may not be necessary. |
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. |
The graph transformation we implement around create_before_destroy
need to re-order all resources that depend on the create_before_destroy
resource. Up until now, we've requires that users mark all of these
resources as create_before_destroy. Data soruces however don't have a
lifecycle block for create_before_destroy, and could not be marked this
way.
This PR checks each DestroyNode that doesn't implement CreateBeforeDestroy
for any ancestors that do implement CreateBeforeDestroy. If there are
any, we inherit the behavior and re-order the graph as such.