Ensure new provider is registered when provider diff is unknown (#4051)

The changes in #4004 caused old provider configuration to be used even when a provider was different between inputs and outputs, in the case that the diff returned DiffUnkown.

To better handle that case, we compute a more accurate (but still conservative) DiffNone or DiffSome so that we can ensure we conservatively update to a new provider when needed, but retain the performance benefit of not creating and configuring a new provider as much as possible.

Part of https://github.com/pulumi/pulumi-aws/issues/814.
This commit is contained in:
Luke Hoban 2020-03-10 19:40:25 -07:00 committed by GitHub
parent e229492d8f
commit 74ffbfd9ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 1263 additions and 3 deletions

View file

@ -2,15 +2,22 @@ CHANGELOG
=========
## HEAD (Unreleased)
* Fix Kubernetes YAML parsing error in .NET.
- Fix Kubernetes YAML parsing error in .NET.
[#4023](https://github.com/pulumi/pulumi/pull/4023)
- Avoid projects beginning with `Pulumi` to stop cyclic imports
[#4013](https://github.com/pulumi/pulumi/pull/4013)
- Ensure we can locate Go created application binaries on Windows
[#4030](https://github.com/pulumi/pulumi/pull/4030)
- Ensure Python overlays work as part of our SDK generation
[#4043](https://github.com/pulumi/pulumi/pull/4043)
- Ensure old provider is not used when configuration has changed
[#4051](https://github.com/pulumi/pulumi/pull/4051)
## 1.12.0 (2020-03-04)
- Avoid Configuring providers which are not used during preview.
[#4004](https://github.com/pulumi/pulumi/pull/4004)

View file

@ -0,0 +1,2 @@
config:
aws:region: us-west-2

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,9 @@
Metadata-Version: 2.1
Name: pulumi-mycomponent
Version: 0.0.1
Summary: MyComponent
Home-page: https://github.com/pulumi/pulumi
License: Apache 2.0
Description: # MyComponent in Python
Platform: UNKNOWN
Description-Content-Type: text/markdown

View file

@ -0,0 +1,8 @@
README.md
setup.py
pulumi_mycomponent/__init__.py
pulumi_mycomponent.egg-info/PKG-INFO
pulumi_mycomponent.egg-info/SOURCES.txt
pulumi_mycomponent.egg-info/dependency_links.txt
pulumi_mycomponent.egg-info/not-zip-safe
pulumi_mycomponent.egg-info/top_level.txt

View file

@ -0,0 +1 @@
pulumi_mycomponent

View file

@ -295,6 +295,13 @@ func (r *Registry) Diff(urn resource.URN, id resource.ID, olds, news resource.Pr
if err != nil {
return plugin.DiffResult{Changes: plugin.DiffUnknown}, err
}
if diff.Changes == plugin.DiffUnknown {
if olds.DeepEquals(news) {
diff.Changes = plugin.DiffNone
} else {
diff.Changes = plugin.DiffSome
}
}
// If the diff requires replacement, unload the provider: the engine will reload it during its replacememnt Check.
//

View file

@ -484,7 +484,7 @@ func TestCRUD(t *testing.T) {
// Diff
diff, err := r.Diff(urn, id, olds, news, false, nil)
assert.NoError(t, err)
assert.Equal(t, plugin.DiffResult{}, diff)
assert.Equal(t, plugin.DiffResult{Changes: plugin.DiffNone}, diff)
// The old provider should still be registered.
p2, ok := r.GetProvider(Reference{urn: urn, id: id})
@ -613,7 +613,7 @@ func TestCRUDPreview(t *testing.T) {
// Diff
diff, err := r.Diff(urn, id, olds, news, false, nil)
assert.NoError(t, err)
assert.Equal(t, plugin.DiffResult{}, diff)
assert.Equal(t, plugin.DiffResult{Changes: plugin.DiffNone}, diff)
// The original provider should be used because the config did not change.
p2, ok := r.GetProvider(Reference{urn: urn, id: id})