Skip to content
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

Separate diff decision from presentation #2379

Merged
merged 86 commits into from
Sep 20, 2024

Conversation

VenelinMartinov
Copy link
Contributor

@VenelinMartinov VenelinMartinov commented Aug 30, 2024

Adds a DiffEqualDecisionOverride to the shim layer which allows provider implementations to specify a diff decision instead of relying on the shim layer to do that.

Also adds a DiffEqualDecisionOverride to the PRC sdkv2 implementation which opentofu does.

Also adds a feature flag EnableAccurateBridgePreview which guards this feature.

will fix once rolled out: #2293
will fix once rolled out: #1501
will undo once rolled out: #1502 as the underlying issue was fixed during the PRC work.
Stacked on #2380

@VenelinMartinov VenelinMartinov changed the base branch from master to vvm/collection_only_detailed_diff_cross_test August 30, 2024 12:59
Copy link

codecov bot commented Aug 30, 2024

Codecov Report

Attention: Patch coverage is 60.34483% with 23 lines in your changes missing coverage. Please review.

Project coverage is 57.41%. Comparing base (9668009) to head (ab1262f).
Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
pkg/tfbridge/provider.go 44.44% 13 Missing and 2 partials ⚠️
pkg/tfshim/sdk-v1/instance_diff.go 0.00% 2 Missing ⚠️
pkg/tfshim/sdk-v2/instance_diff.go 0.00% 2 Missing ⚠️
pkg/tfshim/sdk-v2/provider2.go 91.30% 2 Missing ⚠️
pkg/tfshim/tfplugin5/instance_diff.go 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2379      +/-   ##
==========================================
- Coverage   57.44%   57.41%   -0.03%     
==========================================
  Files         369      369              
  Lines       50189    50230      +41     
==========================================
+ Hits        28831    28841      +10     
- Misses      19779    19809      +30     
- Partials     1579     1580       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@VenelinMartinov VenelinMartinov changed the base branch from vvm/collection_only_detailed_diff_cross_test to vvm/PRC_cleanup August 30, 2024 14:19
pkg/tfshim/shim.go Outdated Show resolved Hide resolved
@t0yv0
Copy link
Member

t0yv0 commented Sep 18, 2024

I've added some nits on the code style but also a couple of higher level questions:

  1. Are corner cases here where we introduced original hacks already covered well by tests, can you point out which ones, I'd like to give it a read to double-check.

  2. Feels like a relatively big deal, originally we talked about rolling this under the "accurate previews" flag, but this PR suggests you're thinking maybe including it in a regular bridge update. Perhaps we have enough confidence to do that, just was making sure it's an informed decision.

  3. Out of scope for this PR, but I wonder if you've noticed collectionDiffs feature; that seems to be still hanging around but I was hoping we can eventually remove this (maybe not yet in this PR), WDYT? It was about explaining these "mysterious diffs" which we computed incorrectly. Perhaps we can file a reminder to clean it out in the Accurate Previews epic.

	if !diff.HasNoChanges() {
		changes = pulumirpc.DiffResponse_DIFF_SOME
		// Perhaps collectionDiffs can shed some light and locate the changes to the end-user.
		for path, diff := range dd.collectionDiffs {
			detailedDiff[path] = diff
		}
	}

@VenelinMartinov
Copy link
Contributor Author

VenelinMartinov commented Sep 19, 2024

Hm, looking at this again, perhaps we can not merge this safely: This changes the Diff/NoDiff decision from being derived from the detailedDiff.

I thought this only affected the workaround added in #1502 but it does have bigger implications - might be best to hold off here and merge as part of the bigger changes.

@VenelinMartinov
Copy link
Contributor Author

On your questions:

Are corner cases here where we introduced original hacks already covered well by tests, can you point out which ones, I'd like to give it a read to double-check.
Did some delving into the git history and here is my understanding:

Feels like a relatively big deal, originally we talked about rolling this under the "accurate previews" flag, but this PR suggests you're thinking maybe including it in a regular bridge update. Perhaps we have enough confidence to do that, just was making sure it's an informed decision.

Yeah, upon revisiting, this might not be safe to merge without a feature flag, will hold off.

Out of scope for this PR, but I wonder if you've noticed collectionDiffs feature; that seems to be still hanging around but I was hoping we can eventually remove this (maybe not yet in this PR), WDYT? It was about explaining these "mysterious diffs" which we computed incorrectly. Perhaps we can file a reminder to clean it out in the Accurate Previews epic.

Yeah, noticed it but it is out of scope for this PR - here I only wanted to separate the Diff/NoDiff decision from the detailed diff - the detailed diff issues should be addressed as part of #2294

Base automatically changed from vvm/PRC_cleanup to master September 19, 2024 13:48
@VenelinMartinov
Copy link
Contributor Author

VenelinMartinov commented Sep 20, 2024

I've added a feature flag for this, along with an env var for it.

I'll set up CI to run with the feature flag so that we do not repeat mistakes from the PRC rollout

pkg/tfbridge/info/info.go Show resolved Hide resolved
pkg/tfshim/sdk-v2/provider2.go Show resolved Hide resolved
pkg/tfshim/shim.go Outdated Show resolved Hide resolved
pkg/tfshim/shim.go Outdated Show resolved Hide resolved
pkg/tfshim/sdk-v2/provider2.go Outdated Show resolved Hide resolved
pkg/tfshim/sdk-v2/provider2.go Outdated Show resolved Hide resolved
pkg/tfshim/shim.go Outdated Show resolved Hide resolved
@t0yv0
Copy link
Member

t0yv0 commented Sep 20, 2024

I'll set up CI to run with the feature flag so that we do not repeat mistakes from the PRC rollout

Excellent, I was just jotting down a ticket to make tests go in a matrix fashion against the flag state space. Thank you.

Copy link
Member

@t0yv0 t0yv0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Very important piece for us.

@VenelinMartinov VenelinMartinov merged commit 22452e6 into master Sep 20, 2024
11 checks passed
@VenelinMartinov VenelinMartinov deleted the vvm/separate_diff_decision branch September 20, 2024 19:26
@pulumi-bot
Copy link
Contributor

This PR has been shipped in release v3.91.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants