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

Fix spurious ForcesProviderReplace activation #1958

Merged
merged 1 commit into from
May 13, 2024

Conversation

t0yv0
Copy link
Member

@t0yv0 t0yv0 commented May 10, 2024

The ForceProviderReplace setting introduces cascading replaces when a certain Provider-level configuration setting changes. For example, changing the region in the AWS Provider is able to recreate all the affected resources in the new desired region with this setting. There was however a practical problem fixed with this PR that caused accidental re-creation of resources in the same region.

Specifically, some of the resources states provisioned by older versions of Pulumi CLI may not have oldInputs sufficiently populated in the call to DetailedDiff. This caused ForceProviderReplace logic to assume that the region is changing from "" to "us-east-1" where it did not, in fact, change. To compensate for this, the logic no longer initiates cascading replace when the oldInputs map does not contain the value.

See also:

The ForceProviderReplace setting introduces cascading replaces when a certain Provider-level configuration setting
changes. For example, changing the region in the AWS Provider is able to recreate all the affected resources in the new
desired region with this setting. There was however a practical problem fixed with this PR that caused accidental
re-creation of resources in the same region.

Specifically, some of the resources states provisioned by older versions of Pulumi CLI may not have oldInputs
sufficiently populated in the call to DetailedDiff. This caused ForceProviderReplace logic to assume that the region is
changing from "" to "us-east-1" where it did not, in fact, change. To compensate for this, the logic no longer initiates
cascading replace when the oldInputs map does not contain the value.

See also:

- pulumi/pulumi-aws#3826
- pulumi/pulumi-aws#3674
@t0yv0 t0yv0 requested review from iwahbe and VenelinMartinov and removed request for iwahbe and VenelinMartinov May 10, 2024 19:38
@t0yv0
Copy link
Member Author

t0yv0 commented May 10, 2024

This seems the most direct approach to the problem but feels a little odd, possibly does not generalize very well and will need to be revisited. If we know of other use cases or approaches let's consider here.

Copy link

codecov bot commented May 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.55%. Comparing base (908bcce) to head (769c8ac).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1958      +/-   ##
==========================================
- Coverage   60.56%   60.55%   -0.01%     
==========================================
  Files         331      331              
  Lines       44722    44726       +4     
==========================================
+ Hits        27084    27085       +1     
- Misses      16116    16118       +2     
- Partials     1522     1523       +1     

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

Copy link
Member

@iwahbe iwahbe left a comment

Choose a reason for hiding this comment

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

I'm fine with this change given the current design.

The need here does make me question the original design. Instead of setting a flag (bool), we should have allowed a diff function

ForceProviderReplace func(ctx context.Context, olds, news resource.PropertyValue) (bool, error)

Copy link
Contributor

@VenelinMartinov VenelinMartinov left a comment

Choose a reason for hiding this comment

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

This looks like something we'd feature flag in the future. I doubt all provider parameters are not really changes when they move from unspecified to specified.

Should we make it opt-in (so needs a change now) or opt out (safe to merge like this, add a feature flag later)?

EDIT: never mind, this is already flagged, we can add another in the future if we find examples of the reverse behaviour. Happy with this.

@t0yv0
Copy link
Member Author

t0yv0 commented May 13, 2024

Yes a callback would be the way to go. This currently has only 1 use case (AWS region) unfortunately. Let's leave as-is but if revisiting go with the callback and deprecate the flag.

@t0yv0 t0yv0 merged commit d57cd0e into master May 13, 2024
11 checks passed
@t0yv0 t0yv0 deleted the t0yv0/fix-forces-provider-replace branch May 13, 2024 14:09
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.

3 participants