terraform: GraphWalkerPanicwrap to catch panics, shadow graph uses it #9852
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to #9840
This PR:
Adds the ability for GraphWalkers to declare they want to catch panics (by implementing
GraphWalkerPanicwrapper
)Modifies the graph walk to turn panics into errors if the above interface is implemented. This makes it so that panics are never able to be completely thrown away. They either crash Terraform or turn into errors that will bubble up.
Modifies shadow graph execution to always capture panics.
This adds some additional robustness around shadow graph execution so that panics during graph walking do not cause Terraform to crash. If this was in place for #9840 then the panic would've shown up as a normal shadow error versus crashing. This would've been okay since the original (non-shadow) graph finished successfully.
This doesn't cover 100% of the scenarios where a shadow graph can crash, but it covers a very large section and one of two most likely areas it would crash (evaluation). The other area would be graph construction itself. This PR doesn't affect the latter positively or negatively.