-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
fix: Router custom-learned-route-priority undefined behavior #12355
Conversation
Hello! I am a robot. Tests will require approval from a repository maintainer to run. @slevenick, 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. |
We see this type of similar issue for advertised_route_policy , @harshithpatte-g made that fix #11613. |
LGTM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an update test that tests this behavior specifically?
I tested it manually by doing a gcloud query for the repro steps. We can't write a test or add into an existing test. |
We should be able to write test check steps to validate that a field is set to a certain value after a config has been applied. That's what we should do here, apply a config with no value and check that it doesn't have one, then apply a config with the 0 value and check that it gets applied, etc. Look for occurrences of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above
I think we can't write the automate test as terraform consider empty or null int field value as 0 . |
We should be able to write a test that sets the field to 0. And then we should be able to verify that Terraform correctly set the value to 0 in the API. Can you add a test that does so? |
Solution to point 1. We don't have it currently as TF SDK doesn't support nil for integer type. The scope of point 1 is greater than just this field. |
Sorry, I think I'm not stating my question well enough. Is 0 a valid value in the API for this field? If so, can the user set that value via their Terraform resource? |
Yes 0 is the valid value for this particular field |
@slevenick This PR has been waiting for review for 3 weekdays. Please take a look! Use the label |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test that specifies custom_learned_route_priority = 0
Specifically we should update from custom_learned_route_priority = 200 to custom_learned_route_priority = 0 to check that the update from another value to 0 works as expected.
The Problem: Before the fix: The custom_learned_route_priority field was unintentionally being set to 0 whenever any other field was updated. This is bad because it could overwrite a user's intentional configuration and they might not notice. Why the second fix is better (but not perfect): cc: @harshithpatte-g |
@slevenick This PR has been waiting for review for 3 weekdays. Please take a look! Use the label |
@GoogleCloudPlatform/terraform-team @slevenick This PR has been waiting for review for 1 week. Please take a look! Use the label |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that in general this change could be ok, but we would need to accompany it with a way for users to set 0 if that's what they intend. This can be done by adding an additional boolean that controls of 0 specifically is sent to the API
@akshat-jindal-nit, this PR is waiting for action from you. If no action is taken, this PR will be closed in 28 days. Please address any comments or change requests, or re-request review from a core reviewer if no action is required. This notification can be disabled with the |
@slevenick This PR has been waiting for review for 3 weekdays. Please take a look! Use the label |
mmv1/third_party/terraform/services/compute/resource_compute_router_peer.go.tmpl
Outdated
Show resolved
Hide resolved
mmv1/third_party/terraform/services/compute/resource_compute_router_bgp_peer_test.go.tmpl
Show resolved
Hide resolved
Tests analyticsTotal tests: 1078 Click here to see the affected service packages
Action takenFound 7 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
🟢 Tests passed during RECORDING mode: 🟢 No issues found for passed tests after REPLAYING rerun. 🔴 Tests failed during RECORDING mode: 🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR. |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 1078 Click here to see the affected service packages
Action takenFound 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
mmv1/third_party/terraform/services/compute/resource_compute_router_peer.go.tmpl
Show resolved
Hide resolved
mmv1/third_party/terraform/services/compute/resource_compute_router_bgp_peer_test.go.tmpl
Outdated
Show resolved
Hide resolved
…outer_bgp_peer_test.go.tmpl Co-authored-by: Sam Levenick <[email protected]>
@slevenick This PR has been waiting for review for 3 weekdays. Please take a look! Use the label |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 0 Click here to see the affected service packages
🔴 Tests were added that are skipped in VCR:
View the build log |
@slevenick can you please re-run the test, there was some typo in it, I correct it. |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 1081 Click here to see the affected service packages
🟢 All tests passed! View the build log |
@GoogleCloudPlatform/terraform-team @slevenick This PR has been waiting for review for 1 week. Please take a look! Use the label |
…loudPlatform#12355) Co-authored-by: Sam Levenick <[email protected]>
Bug: b/378841773
Issue: custom-learned-route-priority is an optional field .
However, TF would set custom-learned-route-priority to be 0 even if the user has not explicitly set the value to be 0 when there is an update to the resource.
Repro steps:
Create a Router peer resource without custom-learned-route-priority value set.
Query gcloud to check the value of custom-learned-route-priority, it will be empty
gcloud compute routers describe {router-name}
Update the router peer resource (ex: advertised_route_priority = 100) without acustom-learned-route-priority. However, TF would add custom-learned-route-priority = 0 in the update api call.
Query gcloud to check the value of custom-learned-route-priority, it will be 0 even though it is not set by the user.
gcloud compute routers describe {router-name}
Release Note Template for Downstream PRs (will be copied)