-
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 global_forwarding_rule labels #12737
Conversation
- enable tests for global_forwarding_rule for `ga` provider - add test for global_forwarding_rule for PSC target - do not send labels for global_forwarding_rule for PSC target
Hello! I am a robot. Tests will require approval from a repository maintainer to run. @BBBmau, 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. |
Tests analyticsTotal tests: 1081 Click here to see the affected service packages
🔴 Tests were added that are GA-only additions and require manual runs:
Action takenFound 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
@@ -0,0 +1,9 @@ | |||
// Labels cannot be set in a create for PSC forwarding rules, so remove it from the CREATE request. | |||
|
|||
if targetProp != nil && |
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.
targetProp != nil
isn't necssary since the field "target"
is a required field: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_global_forwarding_rule.html#target-1
also i'm not familiar with why we can't set labels on create for PSC forwarding rules. Could you direct to me docs that helps me better understand the reason?
we can also change it from ||
-> &&
since for PSC rules it needs to be serviceAttachment. From docs:
For Private Service Connect forwarding rules that forward traffic to managed services, the target must be a service attachment. The target is not mutable once set as a service attachment.
https://cloud.google.com/compute/docs/reference/rest/v1/globalForwardingRules
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.
Ack on targetProp != nil
.
Regarding PSC - one way to detect that this is a PSC target is to check that it has serviceAttachment
, as the docs you link specify.
But there is also special case, documented here where instead of normal serviceAttachment you provide vpc-sc
or all-apis
value, which is also a Private Service Connect endpoint.
Condition strings.Contains(targetProp.(string), "/serviceAttachments/") && targetProp.(string) == "all-apis"
is never true, so I can't change ||
to &&
.
In terms of why it is not possible to set the labels on forwarding rules targeting PSC attachements - I haven't found any reference in public docs, though the same was fixed in #17334 for google_compute_forwarding_rule
.../third_party/terraform/services/compute/resource_compute_global_forwarding_rule_test.go.tmpl
Outdated
Show resolved
Hide resolved
@BBBmau updated the PR, leaving one comment open for you to close, if you're happy with my reply. |
Tests analyticsTotal tests: 1096 Click here to see the affected service packages
🔴 Tests were added that are GA-only additions and require manual runs:
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
|
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.
thanks for providing the explanation in your previous comment!
Approving and merging after all new tests passing as well as forwardingRules_labels
test passing: https://hashicorp.teamcity.com/buildConfiguration/TerraformProviders_GoogleCloud_GOOGLE_MMUPSTREAMTESTS_GOOGLE_PACKAGE_COMPUTE/306442?buildTab=tests
ga
providerFixes: hashicorp/terraform-provider-google#20873
Release Note Template for Downstream PRs (will be copied)
See Write release notes for guidance.