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

RouterBgpPeer BFD support #3258

Merged
merged 2 commits into from
Nov 3, 2021
Merged

Conversation

drebes
Copy link
Member

@drebes drebes commented Mar 17, 2020

Release Note Template for Downstream PRs (will be copied)

compute: Added `bfd` to `google_compute_router_peer`

@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 ( 1 file changed, 36 insertions(+))
Terraform Beta: Diff ( 3 files changed, 561 insertions(+))

@drebes
Copy link
Member Author

drebes commented Mar 17, 2020

This is causing a panic here:

func flattenComputeRouterBgpPeerBfd(v interface{}, d *schema.ResourceData, config *Config) interface{} {
        if v == nil {
                return v
        }
        l := v.([]interface{})

when we read back the bfd block and try to flatten it:

$ make testacc TEST=./google-beta TESTARGS='-run=TestAccComputeRouterPeer_basic'
==> Checking source code against gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google-beta -v -run=TestAccComputeRouterPeer_basic -timeout 240m -ldflags="-X=github.com/terraform-providers/terraform-provider-google-beta/version.ProviderVersion=acc"
=== RUN   TestAccComputeRouterPeer_basic
=== PAUSE TestAccComputeRouterPeer_basic
=== CONT  TestAccComputeRouterPeer_basic
panic: interface conversion: interface {} is map[string]interface {}, not []interface {}

goroutine 572 [running]:
github.com/terraform-providers/terraform-provider-google-beta/google-beta.flattenComputeRouterBgpPeerBfd(0x32c6b60, 0xc000ebe0f0, 0xc000028460, 0xc000897800, 0xc0000ed068, 0x0)
	/Users/drebes/Development/go/src/github.com/terraform-providers/terraform-provider-google-beta/google-beta/resource_compute_router_bgp_peer.go:643 +0x5f1
github.com/terraform-providers/terraform-provider-google-beta/google-beta.resourceComputeRouterBgpPeerRead(0xc000028460, 0x339f140, 0xc000897800, 0x2, 0x2)
...

products/compute/api.yaml Outdated Show resolved Hide resolved
products/compute/api.yaml Outdated Show resolved Hide resolved
products/compute/api.yaml Outdated Show resolved Hide resolved
@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, 43 insertions(+), 3 deletions(-))
Terraform Beta: Diff ( 3 files changed, 567 insertions(+), 3 deletions(-))

Copy link
Contributor

@danawillow danawillow left a comment

Choose a reason for hiding this comment

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

Tests are failing:

TestAccComputeRouterPeer_enable
  === RUN   TestAccComputeRouterPeer_enable
=== PAUSE TestAccComputeRouterPeer_enable
=== CONT  TestAccComputeRouterPeer_enable
--- FAIL: TestAccComputeRouterPeer_enable (272.74s)
    testing.go:635: Step 2 error: errors during apply:
        
        Error: Error updating RouterBgpPeer "projects/ci-test-project-188019/regions/us-central1/routers/router-peer-test-bveczl1ojl/router-peer-test-bveczl1ojl": googleapi: Error 400: Invalid value for field '': ''. Bgp Peer Enable field is not supported yet., invalid
        
          on /opt/teamcity-agent/temp/buildTmp/tf-test516292606/main.tf line 78:
          (source code not available)
        
        
FAIL
TestAccComputeRouterPeer_bfd
  === RUN   TestAccComputeRouterPeer_bfd
=== PAUSE TestAccComputeRouterPeer_bfd
=== CONT  TestAccComputeRouterPeer_bfd
--- FAIL: TestAccComputeRouterPeer_bfd (273.17s)
    testing.go:635: Step 2 error: errors during apply:
        
        Error: Error updating RouterBgpPeer "projects/ci-test-project-188019/regions/us-central1/routers/router-peer-test-b33119hwzx/router-peer-test-b33119hwzx": googleapi: Error 400: Invalid value for field 'project': 'ci-test-project-188019'. Bgp Peer BFD Min Transmit Interval field is not supported yet., invalid
        
          on /opt/teamcity-agent/temp/buildTmp/tf-test782931738/main.tf line 78:
          (source code not available)
        
        
FAIL

products/compute/api.yaml Outdated Show resolved Hide resolved
routing information is removed. If set to TRUE, the peer connection
can be established with routing information. The default is TRUE.
min_version: beta
default_value: "true"
Copy link
Contributor

Choose a reason for hiding this comment

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

Does "true" work here or does it have to be all caps?

Copy link
Member Author

Choose a reason for hiding this comment

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

Surprisingly it does. Regarding your errors this is because the feature is currently in closed Beta requiring project whitelisting, otherwise the fields are unavailable (and a reason why we shouldn't merge before the open Beta is launched, and the enable = TRUE by default will fail if the project is not whitelisted).

@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, 43 insertions(+), 3 deletions(-))
Terraform Beta: Diff ( 3 files changed, 572 insertions(+), 3 deletions(-))

@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, 43 insertions(+), 3 deletions(-))
Terraform Beta: Diff ( 3 files changed, 571 insertions(+), 3 deletions(-))

@drebes
Copy link
Member Author

drebes commented Mar 18, 2020

Tests all pass now, but as it still requires project whitelisting we should hold on merging as it would break peers on TPGB.

$ make testacc TEST=./google-beta TESTARGS='-run=TestAccComputeRouterPeer'
==> Checking source code against gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google-beta -v -run=TestAccComputeRouterPeer -timeout 240m -ldflags="-X=github.com/terraform-providers/terraform-provider-google-beta/version.ProviderVersion=acc"
=== RUN   TestAccComputeRouterPeer_basic
=== PAUSE TestAccComputeRouterPeer_basic
=== RUN   TestAccComputeRouterPeer_advertiseMode
=== PAUSE TestAccComputeRouterPeer_advertiseMode
=== RUN   TestAccComputeRouterPeer_enable
=== PAUSE TestAccComputeRouterPeer_enable
=== RUN   TestAccComputeRouterPeer_bfd
=== PAUSE TestAccComputeRouterPeer_bfd
=== CONT  TestAccComputeRouterPeer_basic
=== CONT  TestAccComputeRouterPeer_bfd
=== CONT  TestAccComputeRouterPeer_enable
=== CONT  TestAccComputeRouterPeer_advertiseMode
--- PASS: TestAccComputeRouterPeer_advertiseMode (185.63s)
--- PASS: TestAccComputeRouterPeer_basic (205.13s)
--- PASS: TestAccComputeRouterPeer_bfd (221.41s)
--- PASS: TestAccComputeRouterPeer_enable (227.80s)
PASS
ok  	github.com/terraform-providers/terraform-provider-google-beta/google-beta	227.851s

@drebes drebes changed the title RouterBgpPeer new attributes [do_not_merge] RouterBgpPeer new attributes Mar 18, 2020
@danawillow
Copy link
Contributor

@drebes what's the current status on this?

@drebes
Copy link
Member Author

drebes commented Jun 10, 2020

Sorry, mixed this with the firewall one. This is on hold as the public beta is delayed.

@drebes drebes changed the title [do_not_merge] RouterBgpPeer new attributes RouterBgpPeer BFD support Oct 28, 2021
@drebes
Copy link
Member Author

drebes commented Oct 28, 2021

BFD finally made it to Public Preview. Unfortunately, BFD on Cloud Routers attached to VPN tunnels has been removed so there is no easy way to implement acceptance tests (Only Partner and Dedicated Interconnect is supported, but Partner interconnected manages the interface and BGP peer automatically, so can't be used for acceptance testing).

@drebes drebes requested review from danawillow and rileykarson and removed request for danawillow October 28, 2021 07:13
@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 ( 1 file changed, 68 insertions(+), 9 deletions(-))
Terraform Beta: Diff ( 12 files changed, 270 insertions(+), 22 deletions(-))

@drebes
Copy link
Member Author

drebes commented Oct 28, 2021

Added integration tests, using VPN. VPN accepts the bfd field as long as the state is set to DISABLED, so we use that.

@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, 402 insertions(+), 9 deletions(-))
Terraform Beta: Diff ( 10 files changed, 406 insertions(+), 12 deletions(-))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccDatasourceGoogleServiceNetworkingPeeredDnsDomain_basic|TestAccCloudbuildWorkerPool_withNetwork|TestAccCloudFunctionsFunction_vpcConnector|TestAccComputeFirewallPolicyRule_update|TestAccComputeForwardingRule_update|TestAccComputeInstanceFromMachineImage_basic|TestAccComputeInstanceFromMachineImage_overrideMetadataDotStartupScript|TestAccComputeInstanceFromMachineImage_diffProject|TestAccComputeOrganizationSecurityPolicyAssociation_organizationSecurityPolicyAssociationBasicExample|TestAccComputeOrganizationSecurityPolicy_organizationSecurityPolicyUpdateExample|TestAccComputeOrganizationSecurityPolicyRule_organizationSecurityPolicyRuleUpdateExample|TestAccComputeRegionNetworkEndpointGroup_regionNetworkEndpointGroupAppengineExample|TestAccComputeRouterPeer_bfd|TestAccContainerAnalysisOccurrence_multipleSignatures|TestAccContainerNodePool_ephemeralStorageConfig|TestAccServiceNetworkingPeeredDNSDomain_basic|TestAccSqlUser_postgresIAM You can view the result here: https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=213519

@rileykarson
Copy link
Member

Hey! Just noting I've seen this and it's in my inbox as a task, I'll get to it within a couple of days.

@modular-magician
Copy link
Collaborator

Tests failed during RECORDING mode: TestAccComputeOrganizationSecurityPolicyRule_organizationSecurityPolicyRuleUpdateExample|TestAccCloudbuildWorkerPool_withNetwork|TestAccContainerAnalysisOccurrence_multipleSignatures|TestAccComputeFirewallPolicyRule_update|TestAccContainerNodePool_ephemeralStorageConfig|TestAccComputeInstanceFromMachineImage_basic|TestAccComputeInstanceFromMachineImage_overrideMetadataDotStartupScript|TestAccComputeRegionNetworkEndpointGroup_regionNetworkEndpointGroupAppengineExample|TestAccCloudFunctionsFunction_vpcConnector|TestAccComputeInstanceFromMachineImage_diffProject|TestAccSqlUser_postgresIAM Please fix these to complete your PR

@@ -675,3 +718,100 @@ resource "google_compute_router_peer" "foobar" {
}
`, routerName, routerName, routerName, routerName, routerName, routerName, routerName, routerName, routerName, routerName, routerName, enable)
}

func testAccComputeRouterPeerBfd(routerName, bfdMode string) string {
Copy link
Member

Choose a reason for hiding this comment

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

What stops us from making this the example? It's a lot of config but if that's required to use the feature, I don't see a problem documenting it! See https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_service_attachment#example-usage---service-attachment-basic for example

Copy link
Member Author

Choose a reason for hiding this comment

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

BFD doesn't make much sense for VPN right now as it can only be DISABLED. A more realistic example is to use it with interconnect but that can't be tested due to the APIs. I'm OK making this a proper example once BFD support for VPN is added, though.

Copy link
Member

Choose a reason for hiding this comment

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

SGTM, thanks!

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

Successfully merging this pull request may close these issues.

5 participants