Skip to content

Add deletion_protection field to Memcache Instance #13603

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

Conversation

rajeshgupthar
Copy link
Contributor

@rajeshgupthar rajeshgupthar commented Apr 9, 2025

Add deletion_protection field to make deletion actions require an explicit intent
Part of b/368232860
Release Note Template for Downstream PRs (will be copied)

See Write release notes for guidance.

memcache: added `deletion_protection` field to `memcache_instance` to make deleting them require an explicit intent. `memcache_instance` resources now cannot be destroyed unless `deletion_protection = false` is set for the resource.

@github-actions github-actions bot requested a review from melinath April 9, 2025 16:50
Copy link

github-actions bot commented Apr 9, 2025

Hello! I am a robot. Tests will require approval from a repository maintainer to run. Googlers: see go/terraform-auto-test-runs to set up automatic test runs.

@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 ( 5 files changed, 101 insertions(+), 224 deletions(-))
google-beta provider: Diff ( 5 files changed, 100 insertions(+), 224 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 0
Passed tests: 0
Skipped tests: 0
Affected tests: 0

Click here to see the affected service packages
  • memcache
#### Non-exercised tests

🔴 Tests were added that are skipped in VCR:

  • TestAccMemcacheInstance_deletionprotection
    🔴 Errors occurred during REPLAYING mode. Please fix them to complete your PR.

View the build log

@SamanthaMathews
Copy link

/gcbrun

Copy link
Member

@melinath melinath left a comment

Choose a reason for hiding this comment

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

whoops, missed actually leaving this review. Please be sure to run tests locally to make sure everything works to speed up the review process! (Especially basic unit tests to make sure the code compiles.)


"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-provider-google/google/acctest"
"github.com/hashicorp/terraform-provider-google/google/envvar"
Copy link
Member

Choose a reason for hiding this comment

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

Causing the tests to not compile:

google-beta/services/memcache/resource_memcache_instance_test.go:12:2: "github.com/hashicorp/terraform-provider-google-beta/google-beta/envvar" imported and not used

Please be sure to run tests locally - at least unit tests - before pushing changes to a PR.

Suggested change
"github.com/hashicorp/terraform-provider-google/google/envvar"

@github-actions github-actions bot requested a review from melinath April 14, 2025 10:20
@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 ( 5 files changed, 100 insertions(+), 224 deletions(-))
google-beta provider: Diff ( 5 files changed, 99 insertions(+), 224 deletions(-))

Missing doc report (experimental)

The following resources have fields missing in documents.

  • google_memcache_instance
    • Expected Document Path: /website/docs/r/memcache_instance.html.markdown
    • Fields: [deletion_protection]

1 similar comment
@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 ( 5 files changed, 100 insertions(+), 224 deletions(-))
google-beta provider: Diff ( 5 files changed, 99 insertions(+), 224 deletions(-))

Missing doc report (experimental)

The following resources have fields missing in documents.

  • google_memcache_instance
    • Expected Document Path: /website/docs/r/memcache_instance.html.markdown
    • Fields: [deletion_protection]

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3
Passed tests: 0
Skipped tests: 0
Affected tests: 3

Click here to see the affected service packages
  • memcache

Action taken

Found 3 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccMemcacheInstance_deletionprotection
  • TestAccMemcacheInstance_memcacheInstanceBasicTestExample
  • TestAccMemcacheInstance_update

Get to know how VCR tests work

1 similar comment
@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3
Passed tests: 0
Skipped tests: 0
Affected tests: 3

Click here to see the affected service packages
  • memcache

Action taken

Found 3 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccMemcacheInstance_deletionprotection
  • TestAccMemcacheInstance_memcacheInstanceBasicTestExample
  • TestAccMemcacheInstance_update

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

🔴 Tests failed during RECORDING mode:
TestAccMemcacheInstance_deletionprotection [Error message] [Debug log]
TestAccMemcacheInstance_memcacheInstanceBasicTestExample [Error message] [Debug log]
TestAccMemcacheInstance_update [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

🔴 Tests failed during RECORDING mode:
TestAccMemcacheInstance_deletionprotection [Error message] [Debug log]
TestAccMemcacheInstance_memcacheInstanceBasicTestExample [Error message] [Debug log]
TestAccMemcacheInstance_update [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test

@@ -37,7 +37,8 @@ async:
base_url: '{{op_id}}'
result:
resource_inside_response: true
custom_code:
custom_code: !ruby/object:Provider::Terraform::CustomCode
Copy link
Member

Choose a reason for hiding this comment

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

This is no longer ruby-based yaml, so this is not necessary.

Suggested change
custom_code: !ruby/object:Provider::Terraform::CustomCode
custom_code:

- name: 'deletion_protection'
description: |
Whether Terraform will be prevented from destroying the instance. Defaults to true.
When a`terraform destroy` or `terraform apply` would delete the instance,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
When a`terraform destroy` or `terraform apply` would delete the instance,
When a `terraform destroy` or `terraform apply` would delete the instance,

},
{
Config: testAccMemcacheInstance_update(prefix, name, network),
},
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
},
},
{
ResourceName: "google_memcache_instance.test",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"reserved_ip_range_id", "deletion_protection"},
},

ExpectError: regexp.MustCompile("deletion_protection"),
},
{
Config: testAccMemcacheInstance_update(prefix, name, network),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Config: testAccMemcacheInstance_update(prefix, name, network),
Config: testAccMemcacheInstance_update(prefix, name, network),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
plancheck.ExpectResourceAction("google_memcache_instance.test", plancheck.ResourceActionUpdate),
},
},

@github-actions github-actions bot requested a review from melinath April 14, 2025 18:32
@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 ( 5 files changed, 117 insertions(+), 224 deletions(-))
google-beta provider: Diff ( 5 files changed, 116 insertions(+), 224 deletions(-))

Missing doc report (experimental)

The following resources have fields missing in documents.

  • google_memcache_instance
    • Expected Document Path: /website/docs/r/memcache_instance.html.markdown
    • Fields: [deletion_protection]

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 0
Passed tests: 0
Skipped tests: 0
Affected tests: 0

Click here to see the affected service packages
  • memcache
#### Non-exercised tests

🔴 Tests were added that are skipped in VCR:

  • TestAccMemcacheInstance_deletionprotection
    🔴 Errors occurred during REPLAYING mode. Please fix them to complete your PR.

View the build log

@github-actions github-actions bot requested a review from melinath April 14, 2025 18:48
Copy link
Member

@melinath melinath left a comment

Choose a reason for hiding this comment

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

there are some gofmt issues that need to be fixed.

@github-actions github-actions bot requested a review from melinath April 14, 2025 18:55
@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@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 ( 5 files changed, 117 insertions(+), 224 deletions(-))
google-beta provider: Diff ( 5 files changed, 117 insertions(+), 224 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3
Passed tests: 0
Skipped tests: 0
Affected tests: 3

Click here to see the affected service packages
  • memcache

Action taken

Found 3 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccMemcacheInstance_deletionprotection
  • TestAccMemcacheInstance_memcacheInstanceBasicTestExample
  • TestAccMemcacheInstance_update

Get to know how VCR tests work

@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 ( 5 files changed, 100 insertions(+), 224 deletions(-))
google-beta provider: Diff ( 5 files changed, 99 insertions(+), 224 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3
Passed tests: 0
Skipped tests: 0
Affected tests: 3

Click here to see the affected service packages
  • memcache

Action taken

Found 3 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccMemcacheInstance_deletionprotection
  • TestAccMemcacheInstance_memcacheInstanceBasicTestExample
  • TestAccMemcacheInstance_update

Get to know how VCR tests work

@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 ( 5 files changed, 100 insertions(+), 224 deletions(-))
google-beta provider: Diff ( 5 files changed, 99 insertions(+), 224 deletions(-))

@modular-magician
Copy link
Collaborator

🔴 Tests failed during RECORDING mode:
TestAccMemcacheInstance_deletionprotection [Error message] [Debug log]
TestAccMemcacheInstance_memcacheInstanceBasicTestExample [Error message] [Debug log]
TestAccMemcacheInstance_update [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3
Passed tests: 0
Skipped tests: 0
Affected tests: 3

Click here to see the affected service packages
  • memcache

Action taken

Found 3 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccMemcacheInstance_deletionprotection
  • TestAccMemcacheInstance_memcacheInstanceBasicTestExample
  • TestAccMemcacheInstance_update

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

🔴 Tests failed during RECORDING mode:
TestAccMemcacheInstance_deletionprotection [Error message] [Debug log]
TestAccMemcacheInstance_memcacheInstanceBasicTestExample [Error message] [Debug log]
TestAccMemcacheInstance_update [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

🔴 Tests failed during RECORDING mode:
TestAccMemcacheInstance_deletionprotection [Error message] [Debug log]
TestAccMemcacheInstance_memcacheInstanceBasicTestExample [Error message] [Debug log]
TestAccMemcacheInstance_update [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

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 ( 5 files changed, 95 insertions(+), 224 deletions(-))
google-beta provider: Diff ( 5 files changed, 95 insertions(+), 224 deletions(-))

1 similar comment
@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 ( 5 files changed, 95 insertions(+), 224 deletions(-))
google-beta provider: Diff ( 5 files changed, 95 insertions(+), 224 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3
Passed tests: 0
Skipped tests: 0
Affected tests: 3

Click here to see the affected service packages
  • memcache

Action taken

Found 3 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccMemcacheInstance_deletionprotection
  • TestAccMemcacheInstance_memcacheInstanceBasicTestExample
  • TestAccMemcacheInstance_update

Get to know how VCR tests work

1 similar comment
@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3
Passed tests: 0
Skipped tests: 0
Affected tests: 3

Click here to see the affected service packages
  • memcache

Action taken

Found 3 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccMemcacheInstance_deletionprotection
  • TestAccMemcacheInstance_memcacheInstanceBasicTestExample
  • TestAccMemcacheInstance_update

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

🔴 Tests failed during RECORDING mode:
TestAccMemcacheInstance_deletionprotection [Error message] [Debug log]
TestAccMemcacheInstance_memcacheInstanceBasicTestExample [Error message] [Debug log]
TestAccMemcacheInstance_update [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

🔴 Tests failed during RECORDING mode:
TestAccMemcacheInstance_deletionprotection [Error message] [Debug log]
TestAccMemcacheInstance_memcacheInstanceBasicTestExample [Error message] [Debug log]
TestAccMemcacheInstance_update [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

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 ( 10 files changed, 180 insertions(+), 102 deletions(-))
google-beta provider: Diff ( 10 files changed, 180 insertions(+), 102 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 17 insertions(+))

Breaking Change(s) Detected

The following breaking change(s) were detected within your pull request.

  • Field deletion_protection within resource google_dataproc_metastore_federation was either removed or renamed - reference

If you believe this detection to be incorrect please raise the concern with your reviewer.
If you intend to make this change you will need to wait for a major release window.
An override-breaking-change label can be added to allow merging.

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_dataproc_metastore_federation (7 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_dataproc_metastore_federation" "primary" {
  tags = # value needed
}

1 similar comment
@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 ( 10 files changed, 180 insertions(+), 102 deletions(-))
google-beta provider: Diff ( 10 files changed, 180 insertions(+), 102 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 17 insertions(+))

Breaking Change(s) Detected

The following breaking change(s) were detected within your pull request.

  • Field deletion_protection within resource google_dataproc_metastore_federation was either removed or renamed - reference

If you believe this detection to be incorrect please raise the concern with your reviewer.
If you intend to make this change you will need to wait for a major release window.
An override-breaking-change label can be added to allow merging.

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_dataproc_metastore_federation (7 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_dataproc_metastore_federation" "primary" {
  tags = # value needed
}

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 38
Passed tests: 32
Skipped tests: 2
Affected tests: 4

Click here to see the affected service packages
  • dataprocmetastore
  • memcache

Action taken

Found 4 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccMetastoreFederation_tags
  • TestAccMemcacheInstance_deletionprotection
  • TestAccMemcacheInstance_memcacheInstanceBasicTestExample
  • TestAccMemcacheInstance_update

Get to know how VCR tests work

1 similar comment
@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 38
Passed tests: 32
Skipped tests: 2
Affected tests: 4

Click here to see the affected service packages
  • dataprocmetastore
  • memcache

Action taken

Found 4 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccMetastoreFederation_tags
  • TestAccMemcacheInstance_deletionprotection
  • TestAccMemcacheInstance_memcacheInstanceBasicTestExample
  • TestAccMemcacheInstance_update

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

🔴 Tests failed during RECORDING mode:
TestAccMemcacheInstance_deletionprotection [Error message] [Debug log]
TestAccMemcacheInstance_memcacheInstanceBasicTestExample [Error message] [Debug log]
TestAccMemcacheInstance_update [Error message] [Debug log]
TestAccMetastoreFederation_tags [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

🟢 Tests passed during RECORDING mode:
TestAccMetastoreFederation_tags [Debug log]

🟢 No issues found for passed tests after REPLAYING rerun.


🔴 Tests failed during RECORDING mode:
TestAccMemcacheInstance_deletionprotection [Error message] [Debug log]
TestAccMemcacheInstance_memcacheInstanceBasicTestExample [Error message] [Debug log]
TestAccMemcacheInstance_update [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test

Copy link
Member

@melinath melinath left a comment

Choose a reason for hiding this comment

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

It looks like some of the previous changes I made on this branch were lost - please re-fix them. I've unresolved the relevant comments.

CheckDestroy: testAccCheckMemcacheInstanceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccMemcacheInstance_deletionprotection(prefix, name, network, "us-central1"),
Copy link
Member

Choose a reason for hiding this comment

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

This function needs to set deletion protection to true. It's currently not, which is why the test is failing to see the expected error in step 3

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.

4 participants