magic-modules icon indicating copy to clipboard operation
magic-modules copied to clipboard

Add reservedInternalRange fields to the google_compute_subnetwork resource

Open daanheikens opened this issue 10 months ago • 5 comments

Fixes: https://github.com/hashicorp/terraform-provider-google/issues/17881

Release Note Template for Downstream PRs (will be copied)

compute: added fields `reserved_internal_range` and `secondary_ip_ranges[].reserved_internal_range` to `google_compute_subnetwork` resource

daanheikens avatar Apr 20 '24 18:04 daanheikens

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

@trodge, 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.

github-actions[bot] avatar Apr 20 '24 19:04 github-actions[bot]

Hi @trodge, happy to receive your review on this PR. Thanks!

daanheikens avatar Apr 23 '24 20:04 daanheikens

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 ( 3 files changed, 98 insertions(+), 6 deletions(-)) google-beta provider: Diff ( 3 files changed, 153 insertions(+), 9 deletions(-)) terraform-google-conversion: Diff ( 1 file changed, 21 insertions(+))

Missing test report

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

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

resource "google_compute_subnetwork" "primary" {
  secondary_ip_range {
    reserved_internal_range = # value needed
  }
}

modular-magician avatar Apr 29 '24 22:04 modular-magician

Tests analytics

Total tests: 906 Passed tests: 833 Skipped tests: 72 Affected tests: 1

Click here to see the affected service packages
  • compute

Action taken

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

Get to know how VCR tests work

modular-magician avatar Apr 29 '24 22:04 modular-magician

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

$\textcolor{red}{\textsf{Please fix these to complete your PR.}}$ View the build log or the debug log for each test

modular-magician avatar Apr 29 '24 22:04 modular-magician

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 ( 3 files changed, 101 insertions(+), 6 deletions(-)) google-beta provider: Diff ( 3 files changed, 159 insertions(+), 9 deletions(-)) terraform-google-conversion: Diff ( 1 file changed, 21 insertions(+))

Missing test report

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

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

resource "google_compute_subnetwork" "primary" {
  secondary_ip_range {
    reserved_internal_range = # value needed
  }
}

modular-magician avatar Apr 30 '24 18:04 modular-magician

Tests analytics

Total tests: 906 Passed tests: 833 Skipped tests: 72 Affected tests: 1

Click here to see the affected service packages
  • compute

Action taken

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

Get to know how VCR tests work

modular-magician avatar Apr 30 '24 18:04 modular-magician

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

$\textcolor{red}{\textsf{Please fix these to complete your PR.}}$ View the build log or the debug log for each test

modular-magician avatar Apr 30 '24 19:04 modular-magician

The test is failing with this error:

2024-04-30T18:59:52.071Z [ERROR] sdk.helper_resource: Unexpected error: test_working_directory=/tmp/plugintest168036712 test_step_number=1
  error=
  | Error running pre-apply refresh: exit status 1
  | 
  | Error: Missing required argument
  | 
  |   on terraform_plugin_test.tf line 2, in resource "google_compute_subnetwork" "subnetwork_with_reserved_internal_range":
  |    2: resource "google_compute_subnetwork" "subnetwork_with_reserved_internal_range" {
  | 
  | The argument "ip_cidr_range" is required, but no definition was found.
   test_name=TestAccComputeSubnetwork_subnetworkReservedInternalRangeExample test_terraform_path=/bin/terraform

trodge avatar May 01 '24 23:05 trodge

The test is failing with this error:

2024-04-30T18:59:52.071Z [ERROR] sdk.helper_resource: Unexpected error: test_working_directory=/tmp/plugintest168036712 test_step_number=1
  error=
  | Error running pre-apply refresh: exit status 1
  | 
  | Error: Missing required argument
  | 
  |   on terraform_plugin_test.tf line 2, in resource "google_compute_subnetwork" "subnetwork_with_reserved_internal_range":
  |    2: resource "google_compute_subnetwork" "subnetwork_with_reserved_internal_range" {
  | 
  | The argument "ip_cidr_range" is required, but no definition was found.
   test_name=TestAccComputeSubnetwork_subnetworkReservedInternalRangeExample test_terraform_path=/bin/terraform

Hey @trodge, It appears that ipCidrRange becomes optional once reserved_internal_range is defined. Currently, it's set as required. What is the recommended approach here? I see two options:

  1. Making ipCidrRange in both primary and secondary ranges optional and document the use case when it's required
  2. Creating custom code to populate those fields once ipCidrRange is empty (in either primary/secondary) and reserved_internal_range is set

I Just tested option 1, setting ipCidrRange to optional and default_from_api to true, then test it again and the test passes.

Happy to hear your thoughts.

daanheikens avatar May 02 '24 18:05 daanheikens

The test is failing with this error:

2024-04-30T18:59:52.071Z [ERROR] sdk.helper_resource: Unexpected error: test_working_directory=/tmp/plugintest168036712 test_step_number=1
  error=
  | Error running pre-apply refresh: exit status 1
  | 
  | Error: Missing required argument
  | 
  |   on terraform_plugin_test.tf line 2, in resource "google_compute_subnetwork" "subnetwork_with_reserved_internal_range":
  |    2: resource "google_compute_subnetwork" "subnetwork_with_reserved_internal_range" {
  | 
  | The argument "ip_cidr_range" is required, but no definition was found.
   test_name=TestAccComputeSubnetwork_subnetworkReservedInternalRangeExample test_terraform_path=/bin/terraform

Hey @trodge, It appears that ipCidrRange becomes optional once reserved_internal_range is defined. Currently, it's set as required. What is the recommended approach here? I see two options:

  1. Making ipCidrRange in both primary and secondary ranges optional and document the use case when it's required
  2. Creating custom code to populate those fields once ipCidrRange is empty (in either primary/secondary) and reserved_internal_range is set

I Just tested option 1, setting ipCidrRange to optional and default_from_api to true, then test it again and the test passes.

Happy to hear your thoughts.

Making the field optional should be fine.

trodge avatar May 02 '24 20:05 trodge

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 ( 3 files changed, 137 insertions(+), 32 deletions(-)) google-beta provider: Diff ( 3 files changed, 195 insertions(+), 35 deletions(-)) terraform-google-conversion: Diff ( 1 file changed, 21 insertions(+))

Missing test report

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

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

resource "google_compute_subnetwork" "primary" {
  secondary_ip_range {
    reserved_internal_range = # value needed
  }
}

modular-magician avatar May 03 '24 23:05 modular-magician

Tests analytics

Total tests: 906 Passed tests: 833 Skipped tests: 72 Affected tests: 1

Click here to see the affected service packages
  • compute

Action taken

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

Get to know how VCR tests work

modular-magician avatar May 04 '24 00:05 modular-magician

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$ TestAccComputeSubnetwork_subnetworkReservedInternalRangeExample[Debug log]

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


$\textcolor{green}{\textsf{All tests passed!}}$ View the build log or the debug log for each test

modular-magician avatar May 04 '24 00:05 modular-magician

It looks like this needed to be reverted due to a breaking change. We will probably need to make this change in the next major release.

trodge avatar May 15 '24 17:05 trodge

It looks like this needed to be reverted due to a breaking change. We will probably need to make this change in the next major release.

Ah pity! Anyway, happy to help. How should we proceed from here @trodge?

daanheikens avatar May 15 '24 20:05 daanheikens

@trodge i saw the announcement for Terraform v6. Is this change coming to v6? I would really be helped having this feature. Is there maybe a way to integrate internal ranges on just the primary range?

daanheikens avatar Jun 04 '24 11:06 daanheikens