stacks: the plan function should stop on validation errors #34720
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.
Currently, we are reporting duplicate diagnostics during the planning stage. This is because we always execute the static evaluation and the dynamic evaluation, whether or not there were errors during the static evaluation. The dynamic evaluation then finds the same errors in the static evaluation, and then both sets are reported.
I think we should return early if the static evaluation finds problems. There's a comment in the
main_plan.go
file that indicates this was the original intent: main_plan.go:106-109. However, this doesn't actually happen. ThereportDiags
function that sets theseenAnyErrors
boolean is never actually called. Instead the walk function just announces the diagnostics directly: main_plan.go:186.This PR makes the walk function process the diagnostics properly, through the
reportDiags
function. This function does still announce the diagnostics, but also tracks errors so that the plan can stop early if we find any. I've also added some tests into plan_test.go, so that we execute the same set of configurations into the both a simple validate and plan operation, that makes sure (a) the plan and validate functions agree on what is or isn't valid configurations and (b) we don't return duplicate diagnostics during the plan anymore.