-
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
Cycle error when removing a resource along with create_before_destroy #26226
Comments
Hi @Nuru Without the full configuration it's hard to determine if there is a legitimate cycle or not, would it be possible to supply all the configuration from Many graph nodes are roughly analogous to the configuration constructs, which represent objects before they are "expanded" into individual instances (currently tagged with |
@jbardin wrote:
Would you please help me understand the output by narrating what it means, and explaining why some lines are missing keys? The way I read it, it says that when trying to come up with a value for I feel pretty sure this is a bug in Terraform, if not #26166 then something like it. When do you expect that bug fix to be available? I would like to see if that bug fix resolves this issue first, because creating a simplified reproducible case could take all day. |
The start and end nodes in that output are not significant, the error can't tell what caused the cycle. Since a cycle has no beginning and end we can't attribute any significance to I doubt it's related to 26166, since there are no module |
@jbardin Thank you for the explanation. While it is true there are no
This error was from applying a successfully generated plan after changing In this case, I hope that is enough for you to go on. If not, I will need some help from you figuring out next steps. The module is complex, and the infrastructure around it is also complex, and I do not know how I can translate this into something you can reproduce on your own. Maybe if you already have a test bed in AWS with an EKS cluster to which you can add a managed node group, you can reproduce the bug with the module I linked to. Please let me know. |
Thanks @Nuru, I'll see what I can glean from the module source. |
Yes. I have seen the error with other similar modules, but this module at tag 0.11.3 is the one that produced the error in #26226 (comment) and is the easiest to understand.
I gave up on trace logging as the logs were in excess of 40,000 lines and I did not know how to redact them. I am willing to continue to work on this with you, but I have limited time available and could use your guidance on how to be more efficient in helping you track down this bug without compromising confidential information. |
Thanks again @Nuru. I have a good hunch on what is going wrong here, but still need to recreate the problem somehow. I believe the That should have been recorded in the state because it's a dependency of another resource which is One odd thing about this module is the attempt to make |
@jbardin Thanks again for digging into this. No, As for making
Terraform could offer an attribute of a resource that says "needs_replacement", although that alone would not be sufficient to use as a "keeper" for random_pet. The lack of such a feature means that we can neither guarantee that
So create-before-destory for node groups comes with its own set of problem. It is an engineering trade-off each user should decide for their situation, so we made it an option. |
Thanks for the update. I have a minimal reproduction here:
This will trigger the same cycle with
|
The cycle can be taken care of by the fix in 26263. This does not completely solve the problem however, since the stale value could now be evaluated. Closing this since it gets past the cycle, and we can now mark this as a duplicate of #25631 |
@jbardin Thank you for taking quick action on this bug. I have some remaining questions:
|
|
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. |
Terraform fails to apply a plan, citing a dependency cycle, but I think that is wrong.
I am not positive, because I do not quite understand how to parse the error message I am getting; maybe if I could understand the message better I would change my mind.
Terraform Version
Terraform Configuration Files
I have a chain of modules that call each other using
for_each
. The actual configuration is far too complicated, but here is a skeleton.Click to show skeleton code
Expected Behavior
terraform plan
produces a plan, so I was expectingterraform apply planfile
to succeed.Actual Behavior
Plan works, but apply yields this error:
I cannot understand this error. In particular, I do not know why the first and last lines are lacking keys. Why is it
module.x.module.y
and notmodule.x["main"].module.y["red"]
? That looks like a bug in the error output to me.In module z,
random_pet
,aws_eks_node_group
, andaws_launch_template
all havecreate_before_destroy = true
. I do not think there is a genuine cycle, but I also do not know how "keepers" are figured in. The plan calls forIf I were doing this by hand, I could follow the above steps like this:
Additional Context
It would really help to have better documentation about how derived values are handled with
create_before_destroy
. I have something likeMy expectation is that internally, Terraform actually keeps 2 versions of
local.launch_template_version
around, one with the value for the template that exists at the beginning of the run and one with the newly created version, so that it can use the right version in the right places.Similarly, I would hope that
random_pet
only changes once. As soon as any of it keepers change, a new pet is created, and its keepers are not saved until the end of the run.References
I do not know if this is related to #26150 or not. That issue had a genuine cycle, and while I think I do not have a genuine cycle, even if I do have one, I think the error message is buggy.
This may or may not be related to/duplicate of #26166 but since the documentation on that is minimal, I cannot tell.
The text was updated successfully, but these errors were encountered: