Skip to content
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

Add fields related to health checked targets to dns_record_set resource #6665

Merged
merged 4 commits into from
Oct 23, 2022

Conversation

roaks3
Copy link
Contributor

@roaks3 roaks3 commented Oct 7, 2022

This resource used to support two types of routing policies: weighted round robin (wrr) and geo location (geo). Now we will be supporting a third option: primary-backup.

In addition, the existing routing types are being updated in two ways:

  • enabled_geo_fencing is being added to support fencing behavior of all geo items
  • health_checked_targets is being added to both wrr and geo, which provides another option for configuring the routing behavior

All together, this work aims to support health checking capabilities for internal load balancers.

b/239887327

If this PR is for Terraform, I acknowledge that I have:

  • Searched through the issue tracker for an open issue that this either resolves or contributes to, commented on it to claim it, and written "fixes {url}" or "part of {url}" in this PR description. If there were no relevant open issues, I opened one and commented that I would like to work on it (not necessary for very small changes).
  • Generated Terraform, and ran make test and make lint to ensure it passes unit and linter tests.
  • Ensured that all new fields I added that can be set by a user appear in at least one example (for generated resources) or third_party test (for handwritten resources or update tests).
  • Ran relevant acceptance tests (If the acceptance tests do not yet pass or you are unable to run them, please let your reviewer know).
  • Read the Release Notes Guide before writing my release note below.

Release Note Template for Downstream PRs (will be copied)

dns: added `primary_backup` to `routing_policy` block of `google_dns_record_set` resource
dns: added `enable_geo_fencing` to `routing_policy` block of `google_dns_record_set` resource
dns: added `health_checked_targets` to `wrr` and `geo` blocks of `google_dns_record_set` resource

@modular-magician
Copy link
Collaborator

Oops! It looks like you're using an unknown release-note type in your changelog entries:

  • REPLACEME

Please only use the types listed in https://github.com/GoogleCloudPlatform/magic-modules/blob/master/.ci/RELEASE_NOTES_GUIDE.md.

@modular-magician
Copy link
Collaborator

Hello! I am a robot who works on Magic Modules PRs.

I've detected that you're a community contributor. @shuyama1, a repository maintainer, has been assigned to assist you and help review your changes.

❓ First time contributing? Click here for more details

Your assigned reviewer will help review your code by:

  • Ensuring it's backwards compatible, covers common error cases, etc.
  • Summarizing the change into a user-facing changelog note.
  • Passes tests, either our "VCR" suite, a set of presubmit tests, or with manual test runs.

You can help make sure that review is quick by running local tests and ensuring they're passing in between each push you make to your PR's branch. Also, try to leave a comment with each push you make, as pushes generally don't generate emails.

If your reviewer doesn't get back to you within a week after your most recent change, please feel free to leave a comment on the issue asking them to take a look! In the absence of a dedicated review dashboard most maintainers manage their pending reviews through email, and those will sometimes get lost in their inbox.


@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 558 insertions(+), 117 deletions(-))
Terraform Beta: Diff ( 3 files changed, 558 insertions(+), 117 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2207
Passed tests 1962
Skipped tests: 240
Failed tests: 5

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccComputeInstance_soleTenantNodeAffinities|TestAccCGCSnippet_eventarcWorkflowsExample|TestAccFirebaserulesRelease_BasicRelease|TestAccDNSRecordSet_routingPolicy|TestAccDNSRecordSet_changeRouting

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccFirebaserulesRelease_BasicRelease[Debug log]
TestAccDNSRecordSet_routingPolicy[Debug log]
TestAccDNSRecordSet_changeRouting[Debug log]

Tests failed during RECORDING mode:
TestAccComputeInstance_soleTenantNodeAffinities[Error message] [Debug log]
TestAccCGCSnippet_eventarcWorkflowsExample[Error message] [Debug log]

Please fix these to complete your PR
View the build log or the debug log for each test

Elem: geoPolicySchema,
ExactlyOneOf: []string{"routing_policy.0.wrr", "routing_policy.0.geo", "routing_policy.0.primary_backup"},
},
"enable_geo_fencing": {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some background on this field:

The API structure for the geo policy is actually an object that contains a list called items. Previously, items was the only field, so it was flattened to a list called geo for the Terraform config. However, enable_fencing was added to the root of the original geo object, and was meant to apply to all items. For example, the new API structure is:

"geo": {
  "enable_fencing": true,
  "items": [
    { "location": "us-central1", rrdatas: [ ... ] }
    { "location": "us-east1", rrdatas: [ ... ] }
  ]
}

If we were to refactor the Terraform config to match this structure, it would be a breaking change, so instead I added the new field one level up, under routing_policy. The field should only apply to geo configurations, so I included "geo" in the name of the field, and added the ConflictsWith constraints you see below to recreate that.

Optional: true,
Description: "Specifies whether to enable fencing for backup geo queries.",
},
"trickle_ratio": {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that gcloud uses trickle_ratio and enabled_geo_fencing field names as well, even though they do not exactly match the API.

Copy link
Member

Choose a reason for hiding this comment

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

Personally I have a slight preference for matching the API but matching gcloud for a handwritten resource seems reasonable.

},
"region": {
Type: schema.TypeString,
Optional: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was not able to come up with a test scenario with an internal load balancer that was global, so I did not confirm whether region was required in this case. I've left it Optional because I assume that it is not needed for global load balancers.

return fmt.Sprintf(`
resource "google_compute_network" "default" {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These test scenarios are loosely based off of https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_forwarding_rule and a set of internal tests that is linked in b/239887327.

load_balancer_type = "regionalL4ilb"
ip_address = google_compute_forwarding_rule.default.ip_address
port = "80"
ip_protocol = "tcp"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should really be google_compute_forwarding_rule.default.project.ip_protocol, but because of the difference in casing, I think users will need to specify it explicitly like this :/

#### Primary-Backup

```hcl
resource "google_dns_record_set" "a" {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

While the tests are probably ok, I think we should have someone from the service team check out that this example actually makes sense for real-world usage, and possibly provide others.

@roaks3
Copy link
Contributor Author

roaks3 commented Oct 8, 2022

I left some comments here because I am going on leave after today, so hopefully they are enough to help whoever picks this up.

@roaks3 roaks3 marked this pull request as ready for review October 8, 2022 01:23
@shuyama1 shuyama1 force-pushed the add-dns-record-set-health-checked-targets branch from 452c135 to 1bec308 Compare October 18, 2022 13:37
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 558 insertions(+), 117 deletions(-))
Terraform Beta: Diff ( 3 files changed, 558 insertions(+), 117 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2193
Passed tests 1952
Skipped tests: 239
Failed tests: 2

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccDNSRecordSet_routingPolicy|TestAccDNSRecordSet_changeRouting

@modular-magician
Copy link
Collaborator

Tests failed during RECORDING mode:
TestAccDNSRecordSet_routingPolicy[Error message] [Debug log]
TestAccDNSRecordSet_changeRouting[Error message] [Debug log]

Please fix these to complete your PR
View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 643 insertions(+), 117 deletions(-))
Terraform Beta: Diff ( 3 files changed, 643 insertions(+), 117 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2193
Passed tests 1951
Skipped tests: 239
Failed tests: 3

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccComputeForwardingRule_update|TestAccDNSRecordSet_changeRouting|TestAccDNSRecordSet_routingPolicy

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccComputeForwardingRule_update[Debug log]
TestAccDNSRecordSet_changeRouting[Debug log]
TestAccDNSRecordSet_routingPolicy[Debug log]

All tests passed
View the build log or the debug log for each test

@shuyama1
Copy link
Member

Additional changes implemented:

  • added network_url expander to handle the field to ensure it can be specified simply with the id of google_compute_network

@shuyama1 shuyama1 force-pushed the add-dns-record-set-health-checked-targets branch from d162bf1 to f795d08 Compare October 19, 2022 15:41
@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.

Terraform GA: Diff ( 3 files changed, 643 insertions(+), 117 deletions(-))
Terraform Beta: Diff ( 3 files changed, 643 insertions(+), 117 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2196
Passed tests 1956
Skipped tests: 239
Failed tests: 1

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccFirebaserulesRelease_BasicRelease

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccFirebaserulesRelease_BasicRelease[Debug log]

All tests passed
View the build log or the debug log for each test

Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"health_checked_targets": {
Copy link
Member

Choose a reason for hiding this comment

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

should this & rrdatas now be marked as either ConflictsWith or ExactlyOneOf?

Copy link
Member

Choose a reason for hiding this comment

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

Based on the API doc, "healthCheckedTargets can be specified along with rrdata within the item". So I guess no ConflictsWith or ExactlyOneOf is needed here. I also tested it locally and it seems that both fields can be specified at the same time.

Optional: true,
Description: "Specifies whether to enable fencing for backup geo queries.",
},
"trickle_ratio": {
Copy link
Member

Choose a reason for hiding this comment

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

Personally I have a slight preference for matching the API but matching gcloud for a handwritten resource seems reasonable.

@shuyama1 shuyama1 merged commit 00669b0 into main Oct 23, 2022
@shuyama1 shuyama1 deleted the add-dns-record-set-health-checked-targets branch October 23, 2022 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants