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

ProviderMeta Issue enrolling GCP resource into PlanResourceChange #1822

Closed
VenelinMartinov opened this issue Apr 1, 2024 · 2 comments · Fixed by #1826
Closed

ProviderMeta Issue enrolling GCP resource into PlanResourceChange #1822

VenelinMartinov opened this issue Apr 1, 2024 · 2 comments · Fixed by #1826
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed

Comments

@VenelinMartinov
Copy link
Contributor

What happened?

While working on pulumi/pulumi-gcp#1874 I attempted to enroll the resource into PlanResourceChange in order to address the diff issue.

Diffing fails with the following error:

--- FAIL: TestConnProfileUpgradePermaDiff (0.21s)
    replay.go:204:
        	Error Trace:	/Users/vvm/go/pkg/mod/github.com/pulumi/[email protected]/replay/replay.go:204
        	            				/Users/vvm/go/pkg/mod/github.com/pulumi/[email protected]/replay/replay.go:186
        	            				/Users/vvm/go/pkg/mod/github.com/pulumi/[email protected]/replay/replay.go:121
        	            				/Users/vvm/go/pkg/mod/github.com/pulumi/[email protected]/replay/replay.go:169
        	            				/Users/vvm/code/pulumi-gcp/provider/provider_yaml_test.go:846
        	Error:      	Received unexpected error:
        	            	ProviderMeta: recoverCtyValue failed: Cannot recover cty.Value
        	            	  Desired type: cty.Object(map[string]cty.Type{"module_name":cty.String})
        	            	  Value: &{{        }    [] pulumi-development     [https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/userinfo.email] 0x140026b77e0 false  0s map[] false  10s 0x140026d1650 context.Background Pulumi/3.0 (GPN:Pulumi; https://www.pulumi.com) pulumi-gcp/dev [{0x14002908088} {0x14002908090}] 0x140028380a0 https://accessapproval.googleapis.com/v1/ https://accesscontextmanager.googleapis.com/v1/ https://managedidentities.googleapis.com/v1beta1/ https://alloydb.googleapis.com/v1beta/ https://apigateway.googleapis.com/v1beta/ https://apigee.googleapis.com/v1/ https://appengine.googleapis.com/v1/ https://apphub.googleapis.com/v1/ https://artifactregistry.googleapis.com/v1/ https://backupdr.googleapis.com/v1/ https://beyondcorp.googleapis.com/v1/ https://biglake.googleapis.com/v1/ https://bigquery.googleapis.com/bigquery/v2/ https://analyticshub.googleapis.com/v1beta1/ https://bigqueryconnection.googleapis.com/v1/ https://bigquerydatapolicy.googleapis.com/v1/ https://bigquerydatatransfer.googleapis.com/v1/ https://bigqueryreservation.googleapis.com/v1/ https://bigtableadmin.googleapis.com/v2/ https://billingbudgets.googleapis.com/v1/ https://binaryauthorization.googleapis.com/v1/ https://blockchainnodeengine.googleapis.com/v1/ https://certificatemanager.googleapis.com/v1/ https://cloudasset.googleapis.com/v1/ https://cloudbuild.googleapis.com/v1/ https://cloudbuild.googleapis.com/v2/ https://clouddeploy.googleapis.com/v1/ https://domains.googleapis.com/v1beta1/ https://cloudfunctions.googleapis.com/v1/ https://cloudfunctions.googleapis.com/v2beta/ https://cloudidentity.googleapis.com/v1beta1/ https://ids.googleapis.com/v1/ https://cloudquotas.googleapis.com/v1/ https://{{location}}-run.googleapis.com/ https://run.googleapis.com/v2/ https://cloudscheduler.googleapis.com/v1/ https://cloudtasks.googleapis.com/v2/ https://compute.googleapis.com/compute/beta/ https://containeranalysis.googleapis.com/v1beta1/ https://{{location}}-gkemulticloud.googleapis.com/v1/ https://cloudbilling.googleapis.com/v1/ https://datamigration.googleapis.com/v1/ https://datacatalog.googleapis.com/v1beta1/ https://dataform.googleapis.com/v1beta1/ https://datafusion.googleapis.com/v1beta1/ https://dlp.googleapis.com/v2/ https://datapipelines.googleapis.com/v1/ https://dataplex.googleapis.com/v1/ https://dataproc.googleapis.com/v1beta2/ https://metastore.googleapis.com/v1beta/ https://datastore.googleapis.com/v1/ https://datastream.googleapis.com/v1/ https://www.googleapis.com/deploymentmanager/v2/ https://dialogflow.googleapis.com/v2/ https://{{location}}-dialogflow.googleapis.com/v3/ https://{{location}}-discoveryengine.googleapis.com/v1/ https://dns.googleapis.com/dns/v1beta2/ https://{{location}}-documentai.googleapis.com/v1/ https://contentwarehouse.googleapis.com/v1/ https://edgecontainer.googleapis.com/v1/ https://edgenetwork.googleapis.com/v1/ https://essentialcontacts.googleapis.com/v1/ https://file.googleapis.com/v1beta1/ https://firebase.googleapis.com/v1beta1/ https://firebaseappcheck.googleapis.com/v1beta/ https://firebasedatabase.googleapis.com/v1beta/ https://firebaseextensions.googleapis.com/v1beta/ https://firebasehosting.googleapis.com/v1beta1/ https://firebasestorage.googleapis.com/v1beta/ https://firestore.googleapis.com/v1/ https://gkebackup.googleapis.com/v1/ https://gkehub.googleapis.com/v1beta1/ https://gkehub.googleapis.com/v1beta/ https://gkeonprem.googleapis.com/v1/ https://healthcare.googleapis.com/v1beta1/ https://iam.googleapis.com/v2beta/ https://iam.googleapis.com/v1/ https://iam.googleapis.com/v1/ https://iap.googleapis.com/v1/ https://identitytoolkit.googleapis.com/v2/ https://connectors.googleapis.com/v1/ https://cloudkms.googleapis.com/v1/ https://logging.googleapis.com/v2/ https://looker.googleapis.com/v1/ https://memcache.googleapis.com/v1beta2/ https://migrationcenter.googleapis.com/v1/ https://ml.googleapis.com/v1/ https://monitoring.googleapis.com/ https://netapp.googleapis.com/v1beta1/ https://networkconnectivity.googleapis.com/v1/ https://networkmanagement.googleapis.com/v1/ https://networksecurity.googleapis.com/v1beta1/ https://networkservices.googleapis.com/v1/ https://notebooks.googleapis.com/v1/ https://orgpolicy.googleapis.com/v2/ https://osconfig.googleapis.com/v1beta/ https://oslogin.googleapis.com/v1/ https://privateca.googleapis.com/v1/ https://publicca.googleapis.com/v1beta1/ https://pubsub.googleapis.com/v1/ https://{{region}}-pubsublite.googleapis.com/v1/admin/ https://redis.googleapis.com/v1beta1/ https://cloudresourcemanager.googleapis.com/v1/ https://runtimeconfig.googleapis.com/v1beta1/ https://secretmanager.googleapis.com/v1/ https://securesourcemanager.googleapis.com/v1/ https://securitycenter.googleapis.com/v1/ https://securityposture.googleapis.com/v1/ https://websecurityscanner.googleapis.com/v1beta/ https://servicedirectory.googleapis.com/v1beta1/ https://servicemanagement.googleapis.com/v1/ https://serviceusage.googleapis.com/v1beta1/ https://sourcerepo.googleapis.com/v1/ https://spanner.googleapis.com/v1/ https://sqladmin.googleapis.com/sql/v1beta4/ https://storage.googleapis.com/storage/v1/ https://storageinsights.googleapis.com/v1/ https://storagetransfer.googleapis.com/v1/ https://cloudresourcemanager.googleapis.com/v3/ https://tpu.googleapis.com/v1/ https://tpu.googleapis.com/v2/ https://{{region}}-aiplatform.googleapis.com/v1beta1/ https://vmwareengine.googleapis.com/v1/ https://vpcaccess.googleapis.com/v1beta1/ https://notebooks.googleapis.com/v2/ https://workflows.googleapis.com/v1/ https://workstations.googleapis.com/v1beta/ https://cloudbilling.googleapis.com/v1/ https://composer.googleapis.com/v1beta1/ https://container.googleapis.com/v1beta1/ https://dataflow.googleapis.com/v1b3/ https://iamcredentials.googleapis.com/v1/ https://cloudresourcemanager.googleapis.com/v3/ https://iam.googleapis.com/v1/  https://servicenetworking.googleapis.com/v1/ https://bigtableadmin.googleapis.com/v2/ https://{{location}}-cloudresourcemanager.googleapis.com/v3/ https://{{location}}-gkemulticloud.googleapis.com/v1/ https://{{location}}-gkemulticloud.googleapis.com/v1/ 0x14002680f00 0x14002680f40}
        	            	  Actual type: *transport.Config
        	            	
        	            	diffing urn:pulumi:dev::connection-profile::gcp:datastream/connectionProfile:ConnectionProfile::dbReplicationConnectionProfile
        	            	github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge.(*Provider).Diff
        	            		/Users/vvm/code/pulumi-terraform-bridge/pkg/tfbridge/provider.go:896
        	            	github.com/pulumi/pulumi-terraform-bridge/x/muxer.(*muxer).Diff.func1
        	            		/Users/vvm/code/pulumi-terraform-bridge/x/muxer/muxer.go:369
        	            	github.com/pulumi/pulumi-terraform-bridge/x/muxer.resourceMethod[...]
        	            		/Users/vvm/code/pulumi-terraform-bridge/x/muxer/muxer.go:334
        	            	github.com/pulumi/pulumi-terraform-bridge/x/muxer.(*muxer).Diff
        	            		/Users/vvm/code/pulumi-terraform-bridge/x/muxer/muxer.go:368
        	            	github.com/pulumi/providertest/replay.replay[...]
        	            		/Users/vvm/go/pkg/mod/github.com/pulumi/[email protected]/replay/replay.go:185
        	            	github.com/pulumi/providertest/replay.Replay
        	            		/Users/vvm/go/pkg/mod/github.com/pulumi/[email protected]/replay/replay.go:121
        	            	github.com/pulumi/providertest/replay.ReplaySequence
        	            		/Users/vvm/go/pkg/mod/github.com/pulumi/[email protected]/replay/replay.go:169
        	            	github.com/pulumi/pulumi-gcp/provider/v7.TestConnProfileUpgradePermaDiff
        	            		/Users/vvm/code/pulumi-gcp/provider/provider_yaml_test.go:846
        	            	testing.tRunner
        	            		/opt/homebrew/Cellar/go/1.22.1/libexec/src/testing/testing.go:1689
        	            	runtime.goexit
        	            		/opt/homebrew/Cellar/go/1.22.1/libexec/src/runtime/asm_arm64.s:1222
        	Test:       	TestConnProfileUpgradePermaDiff
FAIL
exit status 1
FAIL	github.com/pulumi/pulumi-gcp/provider/v7	1.395s

Example

Running TestConnProfileUpgradePermaDiff in pulumi/pulumi-gcp#1890

Output of pulumi about

bridge commit 282c9dd
gcp commit 768e01e

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@VenelinMartinov VenelinMartinov added needs-triage Needs attention from the triage team kind/bug Some behavior is incorrect or out of spec labels Apr 1, 2024
@iwahbe iwahbe removed the needs-triage Needs attention from the triage team label Apr 1, 2024
@VenelinMartinov
Copy link
Contributor Author

The issue happens here:

func (p *planResourceChangeImpl) providerMeta() (*cty.Value, error) {
if p.tf.ProviderMetaSchema == nil {
return nil, nil
}
metaSchema := schema.InternalMap(p.tf.ProviderMetaSchema).CoreConfigSchema()
m := p.tf.Meta()
if m == nil {
v := cty.NullVal(metaSchema.ImpliedType())
return &v, nil
}
v, err := recoverAndCoerceCtyValueWithSchema(metaSchema, m)
if err != nil {
return nil, fmt.Errorf("ProviderMeta: %w", err)
}
return &v, nil
}

Looks like we try to coerce the GCP transport.Config value into a cty.Value and fail.

The GCP config is defined here: https://github.com/hashicorp/terraform-provider-google-beta/blob/99afea8acf81d576b882ec7b4418979139a00e1a/google-beta/transport/config.go#L161

I believe this bit is likely untested since AWS does not define a providerMeta at all.

@VenelinMartinov
Copy link
Contributor Author

VenelinMartinov commented Apr 1, 2024

PlanResourceChange does not seem to help with pulumi/pulumi-gcp#1874 as detailed in pulumi/pulumi-gcp#1874 (comment) so I am going to let it be for now.

EDIT: Discovered this was false. PlanResourceChange change indeed fixes pulumi/pulumi-gcp#1874, so I'm picking this back up.

@VenelinMartinov VenelinMartinov changed the title Issue enrolling GCP resource into PlanResourceChange ProviderMeta Issue enrolling GCP resource into PlanResourceChange Apr 2, 2024
VenelinMartinov added a commit that referenced this issue Apr 9, 2024
fixes #1822 and
unlocks pulumi/pulumi-gcp#1874

`ProviderMeta` seems to be an old experimental feature of TF which has
not picked up.

AWS does not use it and GCP uses it only for one thing - setting
UserAgent strings:
modular-magician/terraform-provider-google-beta@6cf6c51

The meta we receive does not match the schema provided and does not
contain the module_name property. We should set it to null and
potentially revisit if this causes issues. I've tested it for the GCP
resource in #1825
and works fine.


I've opened
#1827 as a
follow-up to test with one of the resources which actually use the
ProviderMeta.

---------

Co-authored-by: Ian Wahbe <[email protected]>
@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants