-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat: Add Pub/Sub Schema support for changing definitions via revisions #8079
feat: Add Pub/Sub Schema support for changing definitions via revisions #8079
Conversation
…sn/magic-modules into pubsub-schema-fixes
Hello! I am a robot who works on Magic Modules PRs. I've detected that you're a community contributor. @shuyama1, a repository maintainer, has been assigned to assist you and help review your changes. ❓ First time contributing? Click here for more detailsYour assigned reviewer will help review your code by:
You can help make sure that review is quick by running local tests and ensuring they're passing in between each push you make to your PR's branch. Also, try to leave a comment with each push you make, as pushes generally don't generate emails. If your reviewer doesn't get back to you within a week after your most recent change, please feel free to leave a comment on the issue asking them to take a look! In the absence of a dedicated review dashboard most maintainers manage their pending reviews through email, and those will sometimes get lost in their inbox. |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 2 files changed, 92 insertions(+), 2 deletions(-)) |
Tests analyticsTotal tests: Action takenFound 11 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected testsTestAccPubsubTopic_pubsubTopicSchemaSettingsExample|TestAccPubsubSchema_pubsubSchemaProtobufExample|TestAccPubsubSchema_pubsubSchemaBasicExample|TestAccBillingSubaccount_basic|TestAccBillingSubaccount_renameOnDestroy|TestAccComputeFirewallPolicyRule_multipleRules|TestAccApigeeKeystoresAliasesPkcs12_ApigeeKeystoresAliasesPkcs12Example|TestAccApigeeKeystoresAliasesKeyCertFile_apigeeKeystoresAliasesKeyCertFileTestExample|TestAccDataSourceGoogleFirebaseAndroidAppConfig|TestAccDataSourceGoogleServiceAccountJwt|TestAccDataSourceAlloydbLocations_basic |
Tests passed during RECORDING mode: Tests failed during RECORDING mode: Please fix these to complete your PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋 This looks good to me, though it would benefit from an acceptance test that reflects that the resource is updatable now!
The google_pubsub_schema
resource has generated tests but no handwritten tests, and handwritten tests are the way we test update behaviours. Could you please add a handwritten test to test updating the resource? There is guidance here and preexisting tests that can be referenced.
@SarahFrench Done. |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 4 files changed, 166 insertions(+), 10 deletions(-)) |
Tests analyticsTotal tests: Action takenFound 9 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected testsTestAccPubsubSchema_update|TestAccDataLossPreventionDeidentifyTemplate_dlpDeidentifyTemplate_infoTypeTransformationsUpdate|TestAccDataLossPreventionDeidentifyTemplate_dlpDeidentifyTemplateSkipCharactersExample|TestAccDataLossPreventionDeidentifyTemplate_dlpDeidentifyTemplateBasicExample|TestAccComputeFirewallPolicyRule_multipleRules|TestAccApigeeKeystoresAliasesKeyCertFile_apigeeKeystoresAliasesKeyCertFileTestExample|TestAccApigeeKeystoresAliasesPkcs12_ApigeeKeystoresAliasesPkcs12Example|TestAccDataSourceGoogleFirebaseAndroidAppConfig|TestAccDataSourceAlloydbLocations_basic |
Tests passed during RECORDING mode: Tests failed during RECORDING mode: Please fix these to complete your PR |
Here's the error output for
Like I said in the other PR I'm at EOD in the UK, but thought that sharing this would help unblock you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like TestAccPubsubSchema_update is failing. I'm not sure what's going on here exactly - I see in the debug logs that there are subsequent GET requests where one returns the new field and the following one does not, but there's no request in between that would change it. Possibly an eventual concurrency problem? (You can search for [ REQUEST ]
to find requests.)
It looks like this is also causing failures related to TGC (which powers gcloud terraform vet
) because of now using the no_send_name.go.erb
expander. This seems potentially more "correct" - if that sounds right to you, you can update mmv1/third_party/validator/tests/data/example_pubsub_schema.json
to remove the name field and that should resolve the error.
Note that this is technically a breaking change for TGC in that people previously relying on the name field being inside the schema would now need to get it from the object overall. But that's okay if the change is more correct. Basically the question is: would the CAI representation of the schema include the name / schema id in the data for the object?
I'll look into what is going on. It is very strange, I could have sworn I ran the acceptance tests and got an "ok" before responding, but I guess something must not have been up to date. |
It looks like this is caused by caching effects in the Pub/Sub service itself. When a new revision is created, it is possible for a read to return the old schema if it was cached locally in the server reached. So there is nothing wrong with the Terraform code here, really. The service can be updated to fix this, but is there a way one generally deals with this kind of caching possibility in these Terraform modules? |
I'm only familiar with how eventual consistency problems are handled on create and delete actions, but from looking at the code generator I think update can also be handled. For example here is an example where a generated resource is defined with an However, the above doesn't seem to be relevant to this error. In the case of the failing acceptance test I can see that the POST request that adds I think the best solution is for the service to be updated to fix this issue - though I defer to @melinath in case he has any insight |
yeah, Terraform can handle eventual consistency on create (by polling until the API resource exists) or on delete (by polling until it doesn't) but I don't think we have a good pattern for handling it on update, since the end states are less binary. The consistency issue would ultimately need to be fixed on the API side; however, that doesn't inherently block this PR being merged; the impact on customers from this would likely be minimal, since there will likely be a longer delay for users between this resource being applied and the next plan being run outside of tests (and it would essentially be idempotent from the user perspective if reapplied). For the tests - if you happen to know how long it would take consistency to be achieved most of the time, I think you could add a (Note that the changes for the terraform-google-conversion tests also still need to happen.) |
The Can you please take a look @SarahFrench or @melinath? Note that the lint errors are for files not touched by this PR. |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 4 files changed, 181 insertions(+), 10 deletions(-)) |
Tests analyticsTotal tests: Action takenFound 10 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected testsTestAccComputeFirewallPolicyRule_multipleRules|TestAccApigeeKeystoresAliasesPkcs12_ApigeeKeystoresAliasesPkcs12Example|TestAccApigeeKeystoresAliasesKeyCertFile_apigeeKeystoresAliasesKeyCertFileTestExample|TestAccDataSourceGoogleFirebaseAndroidAppConfig|TestAccPubsubTopic_pubsubTopicSchemaSettingsExample|TestAccDataSourceAlloydbLocations_basic|TestAccPubsubSchema_update|TestAccPubsubSchema_pubsubSchemaProtobufExample|TestAccLoggingBucketConfigProject_cmekSettings|TestAccPubsubSchema_pubsubSchemaBasicExample |
Tests passed during RECORDING mode: Tests failed during RECORDING mode: Please fix these to complete your PR |
Yes, some flakiness is tolerable (doesn't block merge); we just need to be reasonably certain that we would notice if something changes that breaks the resource. Rerunning the test to try to get a clean recording now that there's a sleep in place. /gcbrun |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 4 files changed, 181 insertions(+), 10 deletions(-)) |
1 similar comment
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are. Terraform GA: Diff ( 4 files changed, 181 insertions(+), 10 deletions(-)) |
Tests analyticsTotal tests: Action takenFound 6 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected testsTestAccApigeeKeystoresAliasesKeyCertFile_apigeeKeystoresAliasesKeyCertFileTestExample|TestAccApigeeKeystoresAliasesPkcs12_ApigeeKeystoresAliasesPkcs12Example|TestAccComputeFirewallPolicyRule_multipleRules|TestAccPubsubSchema_update|TestAccDataSourceGoogleFirebaseAndroidAppConfig|TestAccDataSourceAlloydbLocations_basic |
Tests analyticsTotal tests: Action takenFound 6 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected testsTestAccPubsubSchema_update|TestAccComputeFirewallPolicyRule_multipleRules|TestAccApigeeKeystoresAliasesKeyCertFile_apigeeKeystoresAliasesKeyCertFileTestExample|TestAccApigeeKeystoresAliasesPkcs12_ApigeeKeystoresAliasesPkcs12Example|TestAccDataSourceGoogleFirebaseAndroidAppConfig|TestAccDataSourceAlloydbLocations_basic |
Tests passed during RECORDING mode: Tests failed during RECORDING mode: Please fix these to complete your PR |
Tests passed during RECORDING mode: Tests failed during RECORDING mode: Please fix these to complete your PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving now that the new test's flakiness is minimised and a successful test recording has been made
I'll make an issue so that any necessary follow up (e.g. removing sleeps) is done. Thanks for this! Edit 1: Looking into the exchange above about Edit 2: The integration tests related to tfc are passing, but I don't know why |
@SarahFrench I removed the change to use |
Thanks - I also just spotted that at one point more files in the TF Conversion downstream were affected versus now. I'm happy that I'm not missing anything - merging now |
I believe that the changed have been addressed
…ns (GoogleCloudPlatform#8079) * Add support for Pub/Sub schema evolution * Add example for Pub/Sub schema evolution * Remove changes not to be made in a single PR * Remove changes not to be made in a single PR * Remove changes not to be made in a single PR * Fix spacing * Test update, import * Reduce flakiness
…ns (GoogleCloudPlatform#8079) * Add support for Pub/Sub schema evolution * Add example for Pub/Sub schema evolution * Remove changes not to be made in a single PR * Remove changes not to be made in a single PR * Remove changes not to be made in a single PR * Fix spacing * Test update, import * Reduce flakiness
…ns (GoogleCloudPlatform#8079) * Add support for Pub/Sub schema evolution * Add example for Pub/Sub schema evolution * Remove changes not to be made in a single PR * Remove changes not to be made in a single PR * Remove changes not to be made in a single PR * Fix spacing * Test update, import * Reduce flakiness
Allows schema definition to be changed by committing schema revisions. Fixes hashicorp/terraform-provider-google#13997. This replaces #7981. @SarahFrench and @melinath have the most context on this.
If this PR is for Terraform, I acknowledge that I have:
make test
andmake lint
in the generated providers to ensure it passes unit and linter tests.Release Note Template for Downstream PRs (will be copied)