Skip to content

Validate that subnetwork_project should match with the project in subnetwork field in google_compute_instance resource #11537

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

Merged

Conversation

karolgorc
Copy link
Contributor

@karolgorc karolgorc commented Aug 23, 2024

closes hashicorp/terraform-provider-google#15749

The subnetwork_project field is ignored in the API request when a self_link is given in subnetwork, but not in terraform which is correct behavior because subnetwork_project is still in the code. Suppressing a diff on this seems unreasonable because providing something like this isn't really a valid config

subnetwork_project = "projectA"
subnetwork = "...projectB..."

Maybe throw an error when this happens?

Release Note Template for Downstream PRs (will be copied)

compute: validated that `network_interface.subnetwork_project` should match with the project in `network_interface. subnetwork` field when `network_interface.subnetwork` has full self_link in `google_compute_instance` resource

Copy link

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

@zli82016, 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 github-actions bot requested a review from zli82016 August 23, 2024 12:36
@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Aug 23, 2024
@zli82016
Copy link
Member

/gcbrun

@modular-magician modular-magician added service/compute-instances and removed awaiting-approval Pull requests that need reviewer's approval to run presubmit tests labels Aug 23, 2024
@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 ( 1 file changed, 1 insertion(+), 1 deletion(-))
google-beta provider: Diff ( 1 file changed, 1 insertion(+), 1 deletion(-))

@karolgorc
Copy link
Contributor Author

that unit-test fail doesn't seem related

@zli82016
Copy link
Member

The subnetwork_project field is ignored in the API request when a self_link is given in subnetwork, but not in terraform which is correct behavior because subnetwork_project is still in the code. Suppressing a diff on this seems unreasonable because providing something like this isn't really a valid config

subnetwork_project = "projectA"
subnetwork = "...projectB..."

Maybe throw an error when this happens?

Throwing an error is a good idea to let the user know that the provided subnetwork_project is not correct.

Copy link
Member

@zli82016 zli82016 left a comment

Choose a reason for hiding this comment

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

Can you please add the validation? Thanks.

@github-actions github-actions bot requested a review from zli82016 August 27, 2024 10:32
@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Aug 27, 2024
@karolgorc
Copy link
Contributor Author

  • Added GetProjectFromRegionalSelfLink to tpgresource and a unit test for it
  • Added the new logic to CustomizeDiff

This isn't really a simple field validation to use ValidateFunc because it depends on an external value which isn't really supported by the types used in ValidateFunc, StateFunc or DiffSuppressFunc.

image

@zli82016
Copy link
Member

/gcbrun

@modular-magician modular-magician removed the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Aug 27, 2024
@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 ( 4 files changed, 55 insertions(+), 1 deletion(-))
google-beta provider: Diff ( 4 files changed, 55 insertions(+), 1 deletion(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3921
Passed tests: 3509
Skipped tests: 411
Affected tests: 1

Click here to see the affected service packages

All service packages are affected

#### Non-exercised tests

Tests were added that are skipped in VCR:

  • TestGetProjectFromRegionalSelfLink

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
  • TestAccComputeRegionPerInstanceConfig_removeInstanceOnDestroy

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccComputeRegionPerInstanceConfig_removeInstanceOnDestroy[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
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 ( 4 files changed, 55 insertions(+), 1 deletion(-))
google-beta provider: Diff ( 4 files changed, 55 insertions(+), 1 deletion(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3923
Passed tests: 3510
Skipped tests: 411
Affected tests: 2

Click here to see the affected service packages

All service packages are affected

#### Non-exercised tests

Tests were added that are skipped in VCR:

  • TestGetProjectFromRegionalSelfLink

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
  • TestAccComputeInstanceTemplate_withNamePrefix
  • TestAccComputeTargetHttpsProxy_update

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccComputeInstanceTemplate_withNamePrefix[Debug log]
TestAccComputeTargetHttpsProxy_update[Debug log]
$\textcolor{red}{\textsf{Tests failed when rerunning REPLAYING mode:}}$
TestAccComputeInstanceTemplate_withNamePrefix[Error message] [Debug log]

Tests failed due to non-determinism or randomness when the VCR replayed the response after the HTTP request was made.

Please fix these to complete your PR. If you believe these test failures to be incorrect or unrelated to your change, or if you have any questions, please raise the concern with your reviewer.


$\textcolor{green}{\textsf{All tests passed!}}$

View the build log or the debug log for each test

@karolgorc
Copy link
Contributor Author

Got the same test fails in 2 other PR's. Don't think they are related.

@zli82016 zli82016 changed the title Change doc for google_compute_instance to reflect the correct behaviour of subnetwork_project field Validate that subnetwork_project should match with the project in subnetwork field in google_compute_instance resource Aug 28, 2024
@zli82016
Copy link
Member

zli82016 commented Aug 28, 2024

@karolgorc
Copy link
Contributor Author

Done

@zli82016
Copy link
Member

/gcbrun

@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Aug 29, 2024
@modular-magician modular-magician removed the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Aug 29, 2024
@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, 111 insertions(+), 1 deletion(-))
google-beta provider: Diff ( 5 files changed, 111 insertions(+), 1 deletion(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3934
Passed tests: 3520
Skipped tests: 412
Affected tests: 2

Click here to see the affected service packages

All service packages are affected

#### Non-exercised tests

Tests were added that are skipped in VCR:

  • TestGetProjectFromRegionalSelfLink

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
  • TestAccComputeInstanceTemplate_withNamePrefix
  • TestAccComputeInstance_subnetworkProjectMustMatchError

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccComputeInstanceTemplate_withNamePrefix[Debug log]
TestAccComputeInstance_subnetworkProjectMustMatchError[Debug log]
$\textcolor{red}{\textsf{Tests failed when rerunning REPLAYING mode:}}$
TestAccComputeInstanceTemplate_withNamePrefix[Error message] [Debug log]

Tests failed due to non-determinism or randomness when the VCR replayed the response after the HTTP request was made.

Please fix these to complete your PR. If you believe these test failures to be incorrect or unrelated to your change, or if you have any questions, please raise the concern with your reviewer.


$\textcolor{green}{\textsf{All tests passed!}}$

View the build log or the debug log for each test

Copy link

@zli82016 This PR has been waiting for review for 3 weekdays. Please take a look! Use the label disable-review-reminders to disable these notifications.

Copy link

github-actions bot commented Sep 3, 2024

@GoogleCloudPlatform/terraform-team @zli82016 This PR has been waiting for review for 1 week. Please take a look! Use the label disable-review-reminders to disable these notifications.

Copy link
Member

@zli82016 zli82016 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for adding the validation. The failed tests are unrelated.

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