Backport of don't lose checks from refresh-only plan into v1.3 #32143
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.
Backport
This PR is auto-generated from #32115 to be assessed for backporting due to the inclusion of the label 1.3-backport.
The below text is copied from the body of the original PR.
If there are no changes in a given plan, then there is no reason to create and walk a full apply graph since all objects are known. This means that an apply operation of a refresh plan should only entail returning the planned state.
We however do still need the walk to apply output changes which are recorded in the plan, and some vestigial cleanup is done during the apply walk. In the future, copying the planned output values and cleaning up the state could be done outside the walk, but we will leave that for later pending investigation into any other unexpected side effects it may cause.
For now to ensure refreshed checks are stored correctly, copy the planned checks into the final state after the apply walk.