move RequiresReplace check of plan to Update time instead of Observe & suppress diffs with only computed attributes #341
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.
Description of your changes
Moves the RequiresReplace check of the Plan to start of the Update, instead of Observe.
Currently plans are checked if they return
RequiresReplace
at diff calculation time atObserve
calls, and the plan is refused if they require resource replace with an error due to XRM compliance.However, this prevents late initialization of MR fields with RequiresReplace during initial creation, due to first observe after creation calculates a diff with
RequiresReplace
that gets rejected, since those fields are not late-initialized yet. Then, the diff planning exists early, not letting it reach to late initialization section.Therefore the enforcement of the
RequiresReplace
plans are moved to Update time, to let fields late initialize first and enforce it after update decision is made.Also, this change suppresses diffs with only computed attributes. The current diff detection mechanism compares the plan response and the current state. Plans can contain unknown values for Computed attributes, which is shown as a "false-positive" diff in the current diff logic.
This change suppreses diff elements that has unknown plan value. Note that it does NOT modify the plan itself in any way, just influences the logic of whether there is a diff or not.
I have:
make reviewable
to ensure this PR is ready for review.backport release-x.y
labels to auto-backport this PR if necessary.How has this code been tested
Tested with new opensearchserverless resources in PR crossplane-contrib/provider-upjet-aws#1130 and all existing Terraform Plugin Framework resources