cloudflare / terraform-provider-cloudflare

Cloudflare Terraform Provider
https://registry.terraform.io/providers/cloudflare/cloudflare
Mozilla Public License 2.0
778 stars 599 forks source link

404s on page rules #933

Closed riuvshyn closed 3 years ago

riuvshyn commented 3 years ago

each time I run tf plan / apply it fails on page rules with this:

Error: error from makeRequest: HTTP status 404: content "404 page not found\n"

Error: error from makeRequest: HTTP status 404: content "404 page not found\n"

Error: error from makeRequest: HTTP status 404: content "404 page not found\n"

Error: error from makeRequest: HTTP status 404: content "404 page not found\n"

Error: error from makeRequest: HTTP status 404: content "404 page not found\n"

Error: error from makeRequest: HTTP status 404: content "404 page not found\n"

reproduced on 2.17.0 and 2.18.0 provider versions

Terraform version

13.05

Affected resource(s)

page_rules

Terraform configuration files

Debug output

2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: 181
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: {
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: "result": {
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: "id": "3815a507b2437f1f8e5e5b3b96c4cd22",
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: "targets": [
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: {
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: "target": "url",
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: "constraint": {
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: "operator": "matches",
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: "value": "https:\/\/oc.mydomain.com\/remote.php\/dav\/uploads\/*"
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: }
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: }
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: ],
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: "actions": [
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: {
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: "id": "waf",
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: "value": "off"
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: }
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: ],
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: "priority": 40,
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: "status": "active",
.terraform-provider-cloudflare_v2.18.0: "created_on": "2020-11-06T15:57:46.000000Z",
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: "modified_on": "2020-12-06T12:29:07.000000Z"
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: },
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: "success": true,
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: "errors": [],
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: "messages": []
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: }
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: 0
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0:
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0:
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: -----------------------------------------------------
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: 2021/02/03 14:10:53 [DEBUG] Cloudflare Page Rule read configuration: cloudflare.PageRule{ID:"3815a507b2437f1f8e5e5b3b96c4cd22", Targets:[]cloudflare.PageRuleTarget{cloudflare.PageRuleTarget{Target:"url", Constraint:struct { Operator string "json:\"operator\""; Value string "json:\"value\"" }{Operator:"matches", Value:"https://oc.mydomain.com/remote.php/dav/uploads/*"}}}, Actions:[]cloudflare.PageRuleAction{cloudflare.PageRuleAction{ID:"waf", Value:"off"}}, Priority:40, Status:"active", ModifiedOn:time.Time{wall:0x0, ext:63742854547, loc:(*time.Location)(nil)}, CreatedOn:time.Time{wall:0x0, ext:63740275066, loc:(*time.Location)(nil)}}
2021-02-03T14:10:53.247+0200 [DEBUG] plugin.terraform-provider-cloudflare_v2.18.0: 2021/02/03 14:10:53 [DEBUG] Cloudflare Page Rule actions configuration: map[string]interface {}{"waf":"off"}

Error: error from makeRequest: HTTP status 404: content "404 page not found\n"

Error: error from makeRequest: HTTP status 404: content "404 page not found\n"

Error: error from makeRequest: HTTP status 404: content "404 page not found\n"

2021-02-03T14:10:53.250+0200 [WARN] plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"

Panic output

Expected behavior

not fail

Actual behavior

Steps to reproduce

just do tf plan / apply

Important factoids

amount of 404s each run is different.

References

Community note

jamiemil commented 3 years ago

I have similar issues when trying to run terraform to update worker config.

Various output from this command -

./run_terraform.sh vivastreet.cl apply

that then ends with -

Error: error from makeRequest: HTTP status 404: content "404 page not found\n"

jacobbednarz commented 3 years ago

@riuvshyn I'm afraid I need more information for the reproduction steps and configuration as this doesn't reproduce on just any configuration. Are you able to provide a bare minimum reproduction case on a new installation?

jacobbednarz commented 3 years ago

@jamiemil if your issue isn't the same as the original one (resources, steps, etc) please open a new issue following the issue template provided so we can track them separately.

canthefason commented 3 years ago

We're already in touch with the CF support team regarding this issue, but wanted to share some context here which would help to reproduce it.

After we start running Terraform in debug mode, not sure if it is limited to, but we identified that /client/v4/zones/:zoneid/custom_pages/:custom_page_type endpoint is returning sporadic 404s. And regardless of Terraform, even a basic curl request is giving the exact same response.

jacobbednarz commented 3 years ago

Thanks @canthefason. Looks like this is potential a larger issue with the API and not just Terraform. Let's put this on hold until the internal tickets are addressed.

jacobbednarz commented 3 years ago

NOTE: In the meantime, don't terraform apply changes as most resources that hit 404's will remove the resources from the state file and may end up with undesirable side effects.

jacobbednarz commented 3 years ago

@riuvshyn @jamiemil @canthefason this issue has been mitigated internally and wasn't related to page rules (or Terraform at all) but instead a change to the custom pages service which, unfortunately, the Terraform output doesn't convey well at all. To make matters worse, reproduction wasn't consistent making the diagnosis more annoying than it needs to be. I'm hoping to have a dig into the debug output in the near future and see what we can do about surfacing more useful errors in these scenarios.

Can you please check your Terraform runs again and confirm you're seeing the issue resolved on your end before I close this out?

canthefason commented 3 years ago

thanks for checking in @jacobbednarz, it is all looking good right now.

jacobbednarz commented 3 years ago

awesome, i'm going to close this out but feel free to either ping here or the support tickets if you need more information.

riuvshyn commented 3 years ago

@jacobbednarz awesome! yeh page_rules were just a red herring...