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

pubsub: fix permadiff with configuring an empty retry_policy. #11834

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

anavada
Copy link

@anavada anavada commented Sep 26, 2024

Fixes hashicorp/terraform-provider-google#18016

The permadiff arises when users specify an empty retry policy as retry_policy: {} in their config, but the empty value doesn't get sent to the API and the API subsequently doesn't return a retry_policy in the response. By setting send_empty_value: true on the retry_policy property, we ensure that the API recognizes the user-configured value.

Similar fixes for other resource properties will be investigated and sent in separate PRs.

Release Note Template for Downstream PRs (will be copied)

pubsub: fix permadiff with configuring an empty `retry_policy`.

Copy link

Hello! I am a robot. Tests will require approval from a repository maintainer to run.

@melinath, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 2 files changed, 42 insertions(+), 2 deletions(-))
google-beta provider: Diff ( 2 files changed, 42 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 1 insertion(+), 1 deletion(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 53
Passed tests: 26
Skipped tests: 1
Affected tests: 26

Click here to see the affected service packages
  • pubsub

Action taken

Found 26 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccDataSourceGooglePubsubSubscription_basic
  • TestAccDataSourceGooglePubsubSubscription_optionalProject
  • TestAccPubsubSubscriptionBigQuery_serviceAccount
  • TestAccPubsubSubscriptionBigQuery_update
  • TestAccPubsubSubscriptionCloudStorage_serviceAccount
  • TestAccPubsubSubscriptionCloudStorage_updateAvro
  • TestAccPubsubSubscriptionCloudStorage_updateText
  • TestAccPubsubSubscriptionIamBinding
  • TestAccPubsubSubscriptionIamMember
  • TestAccPubsubSubscriptionIamPolicy
  • TestAccPubsubSubscription_emptyRetryPolicy
  • TestAccPubsubSubscription_emptyTTL
  • TestAccPubsubSubscription_filter
  • TestAccPubsubSubscription_pollOnCreate
  • TestAccPubsubSubscription_pubsubSubscriptionDeadLetterExample
  • TestAccPubsubSubscription_pubsubSubscriptionPullFilterExample
  • TestAccPubsubSubscription_pubsubSubscriptionPushBqExample
  • TestAccPubsubSubscription_pubsubSubscriptionPushBqServiceAccountExample
  • TestAccPubsubSubscription_pubsubSubscriptionPushBqTableSchemaExample
  • TestAccPubsubSubscription_pubsubSubscriptionPushCloudstorageAvroExample
  • TestAccPubsubSubscription_pubsubSubscriptionPushCloudstorageExample
  • TestAccPubsubSubscription_pubsubSubscriptionPushCloudstorageServiceAccountExample
  • TestAccPubsubSubscription_pubsubSubscriptionPushExample
  • TestAccPubsubSubscription_push
  • TestAccPubsubSubscription_pushNoWrapper
  • TestAccPubsubSubscription_pushNoWrapperEmpty

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccDataSourceGooglePubsubSubscription_basic[Debug log]
TestAccDataSourceGooglePubsubSubscription_optionalProject[Debug log]
TestAccPubsubSubscriptionBigQuery_serviceAccount[Debug log]
TestAccPubsubSubscriptionBigQuery_update[Debug log]
TestAccPubsubSubscriptionCloudStorage_serviceAccount[Debug log]
TestAccPubsubSubscriptionCloudStorage_updateAvro[Debug log]
TestAccPubsubSubscriptionCloudStorage_updateText[Debug log]
TestAccPubsubSubscriptionIamBinding[Debug log]
TestAccPubsubSubscriptionIamMember[Debug log]
TestAccPubsubSubscriptionIamPolicy[Debug log]
TestAccPubsubSubscription_emptyRetryPolicy[Debug log]
TestAccPubsubSubscription_emptyTTL[Debug log]
TestAccPubsubSubscription_filter[Debug log]
TestAccPubsubSubscription_pollOnCreate[Debug log]
TestAccPubsubSubscription_pubsubSubscriptionDeadLetterExample[Debug log]
TestAccPubsubSubscription_pubsubSubscriptionPullFilterExample[Debug log]
TestAccPubsubSubscription_pubsubSubscriptionPushBqServiceAccountExample[Debug log]
TestAccPubsubSubscription_pubsubSubscriptionPushCloudstorageAvroExample[Debug log]
TestAccPubsubSubscription_pubsubSubscriptionPushCloudstorageExample[Debug log]
TestAccPubsubSubscription_pubsubSubscriptionPushCloudstorageServiceAccountExample[Debug log]
TestAccPubsubSubscription_pubsubSubscriptionPushExample[Debug log]
TestAccPubsubSubscription_push[Debug log]
TestAccPubsubSubscription_pushNoWrapper[Debug log]
TestAccPubsubSubscription_pushNoWrapperEmpty[Debug log]

$\textcolor{green}{\textsf{No issues found for passed tests after REPLAYING rerun.}}$


$\textcolor{red}{\textsf{Tests failed during RECORDING mode:}}$
TestAccPubsubSubscription_pubsubSubscriptionPushBqExample[Error message] [Debug log]
TestAccPubsubSubscription_pubsubSubscriptionPushBqTableSchemaExample[Error message] [Debug log]

$\textcolor{red}{\textsf{Errors occurred during RECORDING mode. Please fix them to complete your PR.}}$

View the build log or the debug log for each test

@@ -471,6 +471,7 @@ properties:
A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s".
default_from_api: true
diff_suppress_func: 'tpgresource.DurationDiffSuppress'
send_empty_value: true
Copy link
Member

Choose a reason for hiding this comment

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

I think you'll want allow_empty_object here as well, though it looks like the tests are passing, so maybe it's fine? Did you happen to try that out?

Suggested change
send_empty_value: true
send_empty_value: true
allow_empty_object: true

Copy link
Author

Choose a reason for hiding this comment

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

Yeah the earlier BQ-related test failures seem unrelated and are passing now. Thanks for opening hashicorp/terraform-provider-google#19683.

Those tests pass locally as well:

$ make testacc TEST=./google-beta/services/pubsub TESTARGS='-run=TestAccPubsubSubscription_pubsubSubscriptionPushBqExample'
==> Checking that code complies with gofmt requirements...
go vet
TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google-beta/services/pubsub -v -run=TestAccPubsubSubscription_pubsubSubscriptionPushBqExample -timeout 240m -ldflags="-X=github.com/hashicorp/terraform-provider-google-beta/version.ProviderVersion=acc"
=== RUN   TestAccPubsubSubscription_pubsubSubscriptionPushBqExample
=== PAUSE TestAccPubsubSubscription_pubsubSubscriptionPushBqExample
=== CONT  TestAccPubsubSubscription_pubsubSubscriptionPushBqExample
--- PASS: TestAccPubsubSubscription_pubsubSubscriptionPushBqExample (30.70s)
PASS
ok      github.com/hashicorp/terraform-provider-google-beta/google-beta/services/pubsub 31.317s

$ make testacc TEST=./google-beta/services/pubsub TESTARGS='-run=TestAccPubsubSubscription_pubsubSubscriptionPushBqTableSchemaExample'
==> Checking that code complies with gofmt requirements...
go vet
TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google-beta/services/pubsub -v -run=TestAccPubsubSubscription_pubsubSubscriptionPushBqTableSchemaExample -timeout 240m -ldflags="-X=github.com/hashicorp/terraform-provider-google-beta/version.ProviderVersion=acc"
=== RUN   TestAccPubsubSubscription_pubsubSubscriptionPushBqTableSchemaExample
=== PAUSE TestAccPubsubSubscription_pubsubSubscriptionPushBqTableSchemaExample
=== CONT  TestAccPubsubSubscription_pubsubSubscriptionPushBqTableSchemaExample
--- PASS: TestAccPubsubSubscription_pubsubSubscriptionPushBqTableSchemaExample (30.34s)
PASS
ok      github.com/hashicorp/terraform-provider-google-beta/google-beta/services/pubsub 30.958s

Similarly, the "VCR-test" was flaky as well but is passing now. However, the terraform-google-conversion-build-and-unit-tests failures show a permadiff with "retryPolicy": nil, (example test case and test code throwing the error). I think that I'd need to submit a separate PR to fix those tests since they are in a different repo.

I think you'll want allow_empty_object here as well, though it looks like the tests are passing, so maybe it's fine? Did you happen to try that out?

I didn't see that in the field reference but I see it here and used elsewhere in Subscription.yaml. But yeah, the tests are passing with or without allow_empty_object and I'm not sure why, but it doesn't seem like adding allow_empty_object will hurt so I've added it.

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 2 files changed, 42 insertions(+), 2 deletions(-))
google-beta provider: Diff ( 2 files changed, 42 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 1 insertion(+), 1 deletion(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 55
Passed tests: 52
Skipped tests: 1
Affected tests: 2

Click here to see the affected service packages
  • pubsub

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccPubsubSubscription_pubsubSubscriptionPushBqExample
  • TestAccPubsubSubscription_pubsubSubscriptionPushBqTableSchemaExample

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

🟢 Tests passed during RECORDING mode:
TestAccPubsubSubscription_pubsubSubscriptionPushBqExample[Debug log]
TestAccPubsubSubscription_pubsubSubscriptionPushBqTableSchemaExample[Debug log]

🟢 No issues found for passed tests after REPLAYING rerun.


🟢 All tests passed!

View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 2 files changed, 48 insertions(+), 6 deletions(-))
google-beta provider: Diff ( 2 files changed, 48 insertions(+), 6 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 7 insertions(+), 2 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 55
Passed tests: 54
Skipped tests: 1
Affected tests: 0

Click here to see the affected service packages
  • pubsub

🟢 All tests passed!

View the build log

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

Successfully merging this pull request may close these issues.

google_pubsub_subscription TF changes at every plan
3 participants