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

Add deadLetterPolicy to Pub/Sub Subscription resource #3305

Merged
merged 4 commits into from
Mar 30, 2020

Conversation

shaxbee
Copy link
Contributor

@shaxbee shaxbee commented Mar 25, 2020

Support dead_letter_policy as specified in https://pubsub.googleapis.com/$discovery/rest?version=v1

I've tested changes by applying dead_letter_policy with locally build terraform provider following instructions in README.

Release Note Template for Downstream PRs (will be copied)

pubsub: Added `dead_letter_policy` support to `google_pubsub_subscription`

Fixes hashicorp/terraform-provider-google#5522

@modular-magician
Copy link
Collaborator

Hello! I am a robot who works on Magic Modules PRs.

I have detected that you are a community contributor, so your PR will be assigned to someone with a commit-bit on this repo for initial review.

Thanks for your contribution! A human will be with you soon.

@slevenick, please review this PR or find an appropriate assignee.

@shaxbee shaxbee changed the title products/pubsub/api.yaml Add deadLetterPolicy to Pub/Sub Subscription resource Mar 25, 2020
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 2 files changed, 170 insertions(+))
Terraform Beta: Diff ( 2 files changed, 170 insertions(+))
Ansible: Diff ( 2 files changed, 130 insertions(+))
TF Conversion: Diff ( 1 file changed, 45 insertions(+))
Inspec: Diff ( 5 files changed, 49 insertions(+))

@modular-magician
Copy link
Collaborator

Oops! It looks like no changelog entry is attached to this PR. Please include a release note block in the PR body, as described in https://github.com/GoogleCloudPlatform/magic-modules/blob/master/.ci/RELEASE_NOTES_GUIDE.md:

```release-note:TYPE
Release note
```

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 2 files changed, 170 insertions(+))
Terraform Beta: Diff ( 2 files changed, 170 insertions(+))
Ansible: Diff ( 2 files changed, 130 insertions(+))
TF Conversion: Diff ( 1 file changed, 45 insertions(+))
Inspec: Diff ( 5 files changed, 49 insertions(+))

@modular-magician
Copy link
Collaborator

Oops! It looks like you're using an unknown release-note type in your changelog entries:

  • enhancment

Please only use the types listed in https://github.com/GoogleCloudPlatform/magic-modules/blob/master/.ci/RELEASE_NOTES_GUIDE.md.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 2 files changed, 170 insertions(+))
Terraform Beta: Diff ( 2 files changed, 170 insertions(+))
Ansible: Diff ( 2 files changed, 130 insertions(+))
TF Conversion: Diff ( 1 file changed, 45 insertions(+))
Inspec: Diff ( 5 files changed, 49 insertions(+))

@@ -244,3 +244,44 @@ objects:
If ttl is not set, the associated resource never expires.
A duration in seconds with up to nine fractional digits, terminated by 's'.
Example - "3.5s".
- !ruby/object:Api::Type::NestedObject
name: 'deadLetterPolicy'
allow_empty_object: true
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably don't want allow_empty_object here. It will allow us to specify dead_letter_policy {} in a config, which is invalid for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Contributor

@slevenick slevenick left a comment

Choose a reason for hiding this comment

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

Thanks for the addition!

Can I have you add an integration test based on dead letter policies? It can be added as a file that is referenced in the products/pubsub/terraform.yaml examples block for the pubsub subscription.

is disabled.

The Cloud Pub/Sub service account associated with this subscriptions's
parent project (i.e.,\nservice-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have
Copy link
Contributor

Choose a reason for hiding this comment

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

Extra \n in here

Copy link
Contributor Author

@shaxbee shaxbee Mar 27, 2020

Choose a reason for hiding this comment

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

Fixed. Example added as well.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 245 insertions(+))
Terraform Beta: Diff ( 3 files changed, 245 insertions(+))
Ansible: Diff ( 2 files changed, 130 insertions(+))
TF Conversion: Diff ( 1 file changed, 40 insertions(+))
TF OiCS: Diff ( 4 files changed, 118 insertions(+))
Inspec: Diff ( 5 files changed, 49 insertions(+))

@shaxbee
Copy link
Contributor Author

shaxbee commented Mar 27, 2020

@slevenick I have problem troubleshooting integration test failure:

make testacc TEST=./google TESTARGS='-run=TestAccPubsubSubscription_pubsubSubscriptionDeadLetterExample'
==> Checking source code against gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google -v -run=TestAccPubsubSubscription_pubsubSubscriptionDeadLetterExample -timeout 240m -ldflags="-X=github.com/terraform-providers/terraform-provider-google/version.ProviderVersion=acc"
=== RUN   TestAccPubsubSubscription_pubsubSubscriptionDeadLetterExample
=== PAUSE TestAccPubsubSubscription_pubsubSubscriptionDeadLetterExample
=== CONT  TestAccPubsubSubscription_pubsubSubscriptionDeadLetterExample
    TestAccPubsubSubscription_pubsubSubscriptionDeadLetterExample: testing.go:635: Step 0 error: Missing newline after argument: On /var/folders/cj/3yndnndj3hz6jps13xvwzr740000gn/T/tf-test748198000/main.tf line 16: An argument definition must end with a newline.
--- FAIL: TestAccPubsubSubscription_pubsubSubscriptionDeadLetterExample (0.00s)
FAIL
FAIL    github.com/terraform-providers/terraform-provider-google/google 0.666sFAIL
make: *** [testacc] Error 1

I'm using Terraform 0.12.
It seems that something is wrong with generated file but it gets deleted therefore I cannot check it.


expiration_policy {
dead_letter_topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>_dead_letter.id
max_delivery_attempts = <%= ctx[:vars]['max_delivery_attempts'] %>
Copy link
Contributor

Choose a reason for hiding this comment

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

The issue is that this is getting a random suffix added on during generation. Instead of using ctx here, just put the number 10 directly in this config

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@slevenick
Copy link
Contributor

@slevenick I have problem troubleshooting integration test failure:

make testacc TEST=./google TESTARGS='-run=TestAccPubsubSubscription_pubsubSubscriptionDeadLetterExample'
==> Checking source code against gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google -v -run=TestAccPubsubSubscription_pubsubSubscriptionDeadLetterExample -timeout 240m -ldflags="-X=github.com/terraform-providers/terraform-provider-google/version.ProviderVersion=acc"
=== RUN   TestAccPubsubSubscription_pubsubSubscriptionDeadLetterExample
=== PAUSE TestAccPubsubSubscription_pubsubSubscriptionDeadLetterExample
=== CONT  TestAccPubsubSubscription_pubsubSubscriptionDeadLetterExample
    TestAccPubsubSubscription_pubsubSubscriptionDeadLetterExample: testing.go:635: Step 0 error: Missing newline after argument: On /var/folders/cj/3yndnndj3hz6jps13xvwzr740000gn/T/tf-test748198000/main.tf line 16: An argument definition must end with a newline.
--- FAIL: TestAccPubsubSubscription_pubsubSubscriptionDeadLetterExample (0.00s)
FAIL
FAIL    github.com/terraform-providers/terraform-provider-google/google 0.666sFAIL
make: *** [testacc] Error 1

I'm using Terraform 0.12.
It seems that something is wrong with generated file but it gets deleted therefore I cannot check it.

You can see the issue in the downstream generated commit: https://github.com/modular-magician/terraform-provider-google-beta/compare/auto-pr-3305-old..auto-pr-3305#diff-465638d1b1e0cb367d7c78b83d054b32R118

@shaxbee
Copy link
Contributor Author

shaxbee commented Mar 27, 2020

@slevenick Thanks for help, I was able to fix it and integration tests are running successfully now.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 245 insertions(+))
Terraform Beta: Diff ( 3 files changed, 245 insertions(+))
Ansible: Diff ( 2 files changed, 130 insertions(+))
TF Conversion: Diff ( 1 file changed, 40 insertions(+))
TF OiCS: Diff ( 4 files changed, 118 insertions(+))
Inspec: Diff ( 5 files changed, 49 insertions(+))

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 245 insertions(+))
Terraform Beta: Diff ( 3 files changed, 245 insertions(+))
Ansible: Diff ( 2 files changed, 130 insertions(+))
TF Conversion: Diff ( 1 file changed, 40 insertions(+))
TF OiCS: Diff ( 4 files changed, 118 insertions(+))
Inspec: Diff ( 5 files changed, 49 insertions(+))

@slevenick slevenick self-requested a review March 30, 2020 18:39
Copy link
Contributor

@slevenick slevenick left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Thanks for the addition

@slevenick slevenick merged commit 5cb9f2f into GoogleCloudPlatform:master Mar 30, 2020
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.

Add dead letter policy to pubsub
4 participants