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

Added support for LoadBalancer Pool LoadShedding #1108

Merged

Conversation

tpolich
Copy link

@tpolich tpolich commented Jun 22, 2021

Added support for new LoadShedding feature for Cloudflare LoadBalancers. This PR will require a cloudflare-go release / update before it can be merged. See cloudflare/cloudflare-go#658

@jacobbednarz
Copy link
Member

looks like the Import is failing

TF_ACC=1 go test $(go list ./...) -v -run "^TestAccCloudflareLoadBalancerPool_" -timeout 120m -parallel 1
go: downloading github.com/cloudflare/cloudflare-go v0.19.0
?   	github.com/cloudflare/terraform-provider-cloudflare	[no test files]
=== RUN   TestAccCloudflareLoadBalancerPool_Import
=== PAUSE TestAccCloudflareLoadBalancerPool_Import
=== RUN   TestAccCloudflareLoadBalancerPool_Basic
=== PAUSE TestAccCloudflareLoadBalancerPool_Basic
=== RUN   TestAccCloudflareLoadBalancerPool_FullySpecified
=== PAUSE TestAccCloudflareLoadBalancerPool_FullySpecified
=== RUN   TestAccCloudflareLoadBalancerPool_CreateAfterManualDestroy
=== PAUSE TestAccCloudflareLoadBalancerPool_CreateAfterManualDestroy
=== CONT  TestAccCloudflareLoadBalancerPool_Import
panic: interface conversion: interface {} is nil, not string

goroutine 101 [running]:
github.com/hashicorp/terraform-plugin-sdk/helper/schema.HashString(...)
	/Users/jacob/.asdf/installs/golang/1.15.6/packages/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/set.go:17
github.com/cloudflare/terraform-provider-cloudflare/cloudflare.HashByMapKey.func1(0x20cc6c0, 0xc0009bd740, 0xc0008ff210)
	/Users/jacob/go/src/github.com/cloudflare/terraform-provider-cloudflare/cloudflare/utils.go:56 +0xb3
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Set).hash(0xc0008ff200, 0x20cc6c0, 0xc0009bd740, 0x10, 0x20)
	/Users/jacob/.asdf/installs/golang/1.15.6/packages/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/set.go:254 +0x3d
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Set).add(0xc0008ff200, 0x20cc6c0, 0xc0009bd740, 0x0, 0xc0008ff1e0, 0xc0009c6fb0)
	/Users/jacob/.asdf/installs/golang/1.15.6/packages/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/set.go:231 +0x85
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Set).Add(...)
	/Users/jacob/.asdf/installs/golang/1.15.6/packages/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/set.go:75
github.com/hashicorp/terraform-plugin-sdk/helper/schema.NewSet(0xc0008ff1e0, 0xc0005d8c20, 0x1, 0x1, 0x1)
	/Users/jacob/.asdf/installs/golang/1.15.6/packages/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/set.go:62 +0xa5
github.com/cloudflare/terraform-provider-cloudflare/cloudflare.flattenLoadBalancerOrigins(0xc0002cc850, 0xc0005cc540, 0x1, 0x4, 0xc0005d8bd0)
	/Users/jacob/go/src/github.com/cloudflare/terraform-provider-cloudflare/cloudflare/resource_cloudflare_load_balancer_pool.go:386 +0x41d
github.com/cloudflare/terraform-provider-cloudflare/cloudflare.resourceCloudflareLoadBalancerPoolRead(0xc0002cc850, 0x229fd40, 0xc000a12840, 0x1, 0x1)
	/Users/jacob/go/src/github.com/cloudflare/terraform-provider-cloudflare/cloudflare/resource_cloudflare_load_balancer_pool.go:358 +0x925
github.com/cloudflare/terraform-provider-cloudflare/cloudflare.resourceCloudflareLoadBalancerPoolCreate(0xc0002cc850, 0x229fd40, 0xc000a12840, 0x2, 0x2dac340)
	/Users/jacob/go/src/github.com/cloudflare/terraform-provider-cloudflare/cloudflare/resource_cloudflare_load_balancer_pool.go:232 +0x765
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc0002a3ae0, 0xc00031cd20, 0xc0004c6620, 0x229fd40, 0xc000a12840, 0x20c9701, 0xc0002d2108, 0xc0009b9ef0)
	/Users/jacob/.asdf/installs/golang/1.15.6/packages/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/resource.go:320 +0x375
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Apply(0xc000184880, 0xc0009c7a38, 0xc00031cd20, 0xc0004c6620, 0xc0009bf708, 0xc00099d0d0, 0x20cc6c0)
	/Users/jacob/.asdf/installs/golang/1.15.6/packages/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/provider.go:294 +0x99
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc000658028, 0x2532540, 0xc0009b8150, 0xc000329e30, 0xc000658028, 0xc0009b8150, 0xc000070ba0)
	/Users/jacob/.asdf/installs/golang/1.15.6/packages/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/helper/plugin/grpc_provider.go:895 +0x8ab
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x224f100, 0xc000658028, 0x2532540, 0xc0009b8150, 0xc000171bc0, 0x0, 0x2532540, 0xc0009b8150, 0xc0009ba240, 0x21a)
	/Users/jacob/.asdf/installs/golang/1.15.6/packages/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/tfplugin5/tfplugin5.pb.go:3305 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001dc8c0, 0x2541040, 0xc000b1ad80, 0xc00065c400, 0xc0007bb9b0, 0x2d66980, 0x0, 0x0, 0x0)
	/Users/jacob/.asdf/installs/golang/1.15.6/packages/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:1194 +0x522
google.golang.org/grpc.(*Server).handleStream(0xc0001dc8c0, 0x2541040, 0xc000b1ad80, 0xc00065c400, 0x0)
	/Users/jacob/.asdf/installs/golang/1.15.6/packages/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:1517 +0xd05
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc0007a8770, 0xc0001dc8c0, 0x2541040, 0xc000b1ad80, 0xc00065c400)
	/Users/jacob/.asdf/installs/golang/1.15.6/packages/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:859 +0xa5
created by google.golang.org/grpc.(*Server).serveStreams.func1
	/Users/jacob/.asdf/installs/golang/1.15.6/packages/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:857 +0x1fd
FAIL	github.com/cloudflare/terraform-provider-cloudflare/cloudflare	2.539s
?   	github.com/cloudflare/terraform-provider-cloudflare/version	[no test files]
FAIL
make: *** [testacc] Error 1

@@ -314,7 +383,19 @@ func flattenLoadBalancerOrigins(d *schema.ResourceData, origins []cloudflare.Loa

flattened = append(flattened, cfg)
}
return schema.NewSet(schema.HashResource(originsElem), flattened)
return schema.NewSet(HashByMapKey("load_shedding"), flattened)
Copy link
Member

@jacobbednarz jacobbednarz Jul 16, 2021

Choose a reason for hiding this comment

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

this is the problematic bit; unsure why we're looking to return this value here as it doesn't seem related to the block it is in 🤔. typo or miscopy/paste?

@tpolich tpolich force-pushed the load_balancer_load_shedding_support branch from 30e8a0a to c0c4364 Compare July 16, 2021 23:51
@jacobbednarz
Copy link
Member

with my latest push for the TypeSet indexes in the tests, we're good to go here

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./...) -v -run "^TestAccCloudflareLoadBalancerPool_" -timeout 120m -parallel 1
?   	github.com/cloudflare/terraform-provider-cloudflare	[no test files]
=== RUN   TestAccCloudflareLoadBalancerPool_Import
=== PAUSE TestAccCloudflareLoadBalancerPool_Import
=== RUN   TestAccCloudflareLoadBalancerPool_Basic
=== PAUSE TestAccCloudflareLoadBalancerPool_Basic
=== RUN   TestAccCloudflareLoadBalancerPool_FullySpecified
=== PAUSE TestAccCloudflareLoadBalancerPool_FullySpecified
=== RUN   TestAccCloudflareLoadBalancerPool_CreateAfterManualDestroy
=== PAUSE TestAccCloudflareLoadBalancerPool_CreateAfterManualDestroy
=== CONT  TestAccCloudflareLoadBalancerPool_Import
--- PASS: TestAccCloudflareLoadBalancerPool_Import (2.69s)
=== CONT  TestAccCloudflareLoadBalancerPool_CreateAfterManualDestroy
--- PASS: TestAccCloudflareLoadBalancerPool_CreateAfterManualDestroy (4.33s)
=== CONT  TestAccCloudflareLoadBalancerPool_FullySpecified
--- PASS: TestAccCloudflareLoadBalancerPool_FullySpecified (2.93s)
=== CONT  TestAccCloudflareLoadBalancerPool_Basic
--- PASS: TestAccCloudflareLoadBalancerPool_Basic (2.56s)
PASS
ok  	github.com/cloudflare/terraform-provider-cloudflare/cloudflare	12.890s
?   	github.com/cloudflare/terraform-provider-cloudflare/version	[no test files]

@jacobbednarz jacobbednarz merged commit 4ef3abf into cloudflare:master Jul 18, 2021
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.

2 participants