-
Notifications
You must be signed in to change notification settings - Fork 630
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
resource/cloudflare_ruleset: fix ruleset category overrides in DDoS L7 phase by allowing the provider to omit the enabled
flag, as required by Cloudflare's API
#1492
resource/cloudflare_ruleset: fix ruleset category overrides in DDoS L7 phase by allowing the provider to omit the enabled
flag, as required by Cloudflare's API
#1492
Conversation
Oops! It looks like no changelog entry is attached to this PR. Please include a release note as described in https://github.com/cloudflare/terraform-provider-cloudflare/blob/master/docs/changelog-process.md. Example:
If you do not require a release note to be included, please add the |
…7 phase by allowing the provider to omit the `enabled` flag, as required by Cloudflare's API In the DDoS L7 phase, category overrides do not support the `enabled` flag which must therefore be omitted. ``` DDoS L7 overrides cannot use the enabled field, DDoS L7 overrides cannot use the enabled field ``` Requires the following cloudflare-go schema: cloudflare/cloudflare-go#824
…CloudflareRulesetStateUpgradeV0ToV1 Introduced in #1477, resourceCloudflareRulesetStateUpgradeV0ToV1 might panic because no checks are performed. I do not possess the required knowledge to perfectly understand the ins/outs of this migration, therefore simply adding a broad recovery clause in the event the migration is not possible (e.g as below where a nil object is given). ``` 2022-03-04T15:16:52.440+0800 [DEBUG] plugin.terraform-provider-cloudflare_99.0.0: panic: interface conversion: interface {} is nil, not []map[string]interface {} panic: interface conversion: interface {} is nil, not []map[string]interface {} goroutine 301 [running]: github.com/cloudflare/terraform-provider-cloudflare/cloudflare.resourceCloudflareRulesetStateUpgradeV0ToV1({0x1e97838, 0xc0008f8600}, 0xc000349bc0, {0x1dca880, 0xc0004a06c0}) go/src/github.com/cloudflare/terraform-provider-cloudflare/cloudflare/resource_cloudflare_ruleset_migrate.go:344 +0x2d1 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).upgradeJSONState(0xc00041c048, {0x1e97838, 0xc0008f8600}, 0x0, 0xc000349bc0, 0xc000495a40) go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:424 +0x1c3 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).UpgradeResourceState(0xc00041c048, {0x1e97838, 0xc0008f8600}, 0xc0007fa420) go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:300 +0x645 github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).UpgradeResourceState(0xc0004366e0, {0x1e97838, 0xc0008f8600}, 0xc000bdc230) go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:715 +0x532 github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_UpgradeResourceState_Handler({0x1d9d380, 0xc0004366e0}, {0x1e978e0, 0xc0004b0480}, 0xc0001b0600, 0x0) go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:313 +0x385 google.golang.org/grpc.(*Server).processUnaryRPC(0xc0004d0000, {0x1ea4828, 0xc000483040}, 0xc000e80240, 0xc0004b1a70, 0x23e38e0, 0x0) go/pkg/mod/google.golang.org/[email protected]/server.go:1282 +0x14c9 google.golang.org/grpc.(*Server).handleStream(0xc0004d0000, {0x1ea4828, 0xc000483040}, 0xc000e80240, 0x0) go/pkg/mod/google.golang.org/[email protected]/server.go:1616 +0x85e google.golang.org/grpc.(*Server).serveStreams.func1.2() go/pkg/mod/google.golang.org/[email protected]/server.go:921 +0x11d created by google.golang.org/grpc.(*Server).serveStreams.func1 go/pkg/mod/google.golang.org/[email protected]/server.go:919 +0x345 ```
Resource creation now works appropriately, however, it appears that Launching a debugger against the following state:
Results in Ultimately, I feel like trying to use a tristate TypeBool with Terraform is bound to failure as cty/TF don't appear to be able to write/read the state file while maintaining the tri-state status. This leads to I won't get too lost into writing some kind of fix implementation given I am not super-duper experienced writing providers, I don't have a solution that doesn't sound gross, there probably is a different issue/approach I'm not seeing). |
FWIW, this isn’t the first time we’ve tangled with tristate booleans…I have a SDK bug open to address exactly this (hashicorp/terraform-plugin-sdk#817) |
Yeah, I've been reading that thread while trying to fix up the provider, looks fundamentally broken. I am not 100% sure how the SDK/cty ends up writing a |
// Broadly intercept the panic generated from our inability to perform the upgrade. | ||
defer func() { | ||
if err := recover(); err != nil { | ||
log.Printf("[DEBUG] Unable to perform resourceCloudflareRulesetStateUpgradeV0ToV1") | ||
} | ||
}() | ||
|
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 remove this; it doesn't actually help the upgrade process. there was an update to the migrate in another PR.
looks like you'll need to update from |
Marking this pull request as stale due to 14 days of inactivity. This helps our maintainers find and focus on the active pull requests. If this pull request receives no comments in the next 7 days it will automatically be closed. Maintainers can also remove the |
This PR was closed because it has been stalled for 7 days with no activity. |
In the DDoS L7 phase, category overrides do not support the
enabled
flag which must therefore be omitted. This is pretty closely related to #1405.Terraform example
API Request (sample) & error before this PR
Leading to the following
400 Bad Request
error returned by the Cloudflare API (doubled, because two categories):API Request (sample) after this PR
Notes