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

failed to execute http request #170

Closed
arogic opened this issue Jun 1, 2023 · 10 comments
Closed

failed to execute http request #170

arogic opened this issue Jun 1, 2023 · 10 comments
Labels
question Further information is requested

Comments

@arogic
Copy link

arogic commented Jun 1, 2023

Hi there,

Getting below Error Error: failed to execute http request, but when I run a curl command (curl -u ${sonarqube_token}: https://<sonarqube-fqdn>/api/system/info) from the same Machine it works.

Terraform Version

Terraform v1.4.5
Terraform SonarQube Provider Version: 0.16.1

Affected Resource(s)

all resources (group, project, permissions)

Actual Behavior

What actually happened?

Error: failed to execute http request: GET https://<token>:@<sonarqube fqdn>/api/system/info? giving up after 5 attempt(s). Request: &{0x16a4400 <nil> 0xc0000b8800}

   with provider["registry.terraform.io/jdamata/sonarqube"],
   on sonarqube.tf line 9, in provider "sonarqube":
    9: provider "sonarqube" {

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform plan

Thanks in advance.

@jdamata
Copy link
Owner

jdamata commented Jun 2, 2023

What kind of terraform provider configuration do you have set?

@jdamata jdamata added the question Further information is requested label Jun 2, 2023
@arogic
Copy link
Author

arogic commented Jun 2, 2023

Hi, please find below my terraform provider configuration.

provider "sonarqube" {
  # Configuration options
  token = var.sonarqube_token
  host  = var.sonarqube_host
}

Regards

@arogic
Copy link
Author

arogic commented Jun 5, 2023

Hi, please find below a snippet of the terraform plan output with TF_LOG="DEBUG" enabled.

...
2023-06-05T08:07:23.378+0200 [DEBUG] Starting graph walk: walkPlan
2023-06-05T08:07:23.378+0200 [DEBUG] created provider logger: level=debug
2023-06-05T08:07:23.378+0200 [INFO]  provider: configuring client automatic mTLS
2023-06-05T08:07:23.385+0200 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/jdamata/sonarqube/0.16.1/darwin_amd64/terraform-provider-sonarqube_v0.16.1 args=[.terraform/providers/registry.terraform.io/jdamata/sonarqube/0.16.1/darwin_amd64/terraform-provider-sonarqube_v0.16.1]
2023-06-05T08:07:23.389+0200 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/jdamata/sonarqube/0.16.1/darwin_amd64/terraform-provider-sonarqube_v0.16.1 pid=14899
2023-06-05T08:07:23.389+0200 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/jdamata/sonarqube/0.16.1/darwin_amd64/terraform-provider-sonarqube_v0.16.1
2023-06-05T08:07:23.402+0200 [INFO]  provider.terraform-provider-sonarqube_v0.16.1: configuring server automatic mTLS: timestamp=2023-06-05T08:07:23.401+0200
2023-06-05T08:07:23.420+0200 [DEBUG] provider: using plugin: version=5
2023-06-05T08:07:23.420+0200 [DEBUG] provider.terraform-provider-sonarqube_v0.16.1: plugin address: address=/var/folders/zg/wmlhg1wx6kxdfjsm6rt4bx2h0000gn/T/plugin3511947945 network=unix timestamp=2023-06-05T08:07:23.420+0200
2023-06-05T08:07:23.443+0200 [WARN]  ValidateProviderConfig from "provider[\"registry.terraform.io/jdamata/sonarqube\"]" changed the config value, but that value is unused
2023-06-05T08:07:23.444+0200 [DEBUG] provider.terraform-provider-sonarqube_v0.16.1: 2023/06/05 08:07:23 [DEBUG] GET https://<token>:@<sonarqube-fqdn>/api/system/info?
2023-06-05T08:07:23.661+0200 [DEBUG] provider.terraform-provider-sonarqube_v0.16.1: 2023/06/05 08:07:23 [DEBUG] GET https://<token>:@<sonarqube-fqdn>/api/system/info? (status: 502): retrying in 1s (4 left)
2023-06-05T08:07:24.692+0200 [DEBUG] provider.terraform-provider-sonarqube_v0.16.1: 2023/06/05 08:07:24 [DEBUG] GET https://<token>:@<sonarqube-fqdn>/api/system/info? (status: 502): retrying in 2s (3 left)
2023-06-05T08:07:26.745+0200 [DEBUG] provider.terraform-provider-sonarqube_v0.16.1: 2023/06/05 08:07:26 [DEBUG] GET https://<token>:@<sonarqube-fqdn>/api/system/info? (status: 502): retrying in 4s (2 left)
2023-06-05T08:07:30.780+0200 [DEBUG] provider.terraform-provider-sonarqube_v0.16.1: 2023/06/05 08:07:30 [DEBUG] GET https://<token>:@<sonarqube-fqdn>/api/system/info? (status: 502): retrying in 8s (1 left)
2023-06-05T08:07:38.829+0200 [ERROR] provider.terraform-provider-sonarqube_v0.16.1: Response contains error diagnostic: tf_proto_version=5.3 tf_provider_addr=registry.terraform.io/jdamata/sonarqube @caller=github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/diag/diagnostics.go:55 diagnostic_detail= diagnostic_severity=ERROR diagnostic_summary="failed to execute http request: GET https://<token>:@<sonarqube-fqdn>/api/system/info? giving up after 5 attempt(s). Request: &{0x16a4400 <nil> 0xc0000b6e00}" @module=sdk.proto tf_req_id=2fb699fb-4a9d-8f2c-6c40-67ee884c847e tf_rpc=Configure timestamp=2023-06-05T08:07:38.829+0200
2023-06-05T08:07:38.830+0200 [ERROR] vertex "provider[\"registry.terraform.io/jdamata/sonarqube\"]" error: failed to execute http request: GET https://<token>:@<sonarqube-fqdn>/api/system/info? giving up after 5 attempt(s). Request: &{0x16a4400 <nil> 0xc0000b6e00}
...

Found this Issue hashicorp/terraform-plugin-go#285, but not sure if it is related to mine?

Regards

@jdamata
Copy link
Owner

jdamata commented Jun 5, 2023

I don't see how that issue is related. What stands out to me is that your debug logs shows sonarqube api responding with a (status: 502). So it seems like the provider is able to reach out to your sonarqube instance but is getting a 502 back instead of the proper response.

Is there anything in sonarqube logs when these failures happen?

@arogic
Copy link
Author

arogic commented Jun 6, 2023

Thanks, I'll check the SonarQube Logs and will get back to you.

@arogic
Copy link
Author

arogic commented Jun 6, 2023

I wasn't able to find anything so far in the SonarQube Logs. The Log Level is currently set to "INFO". I requested to get the Log Level set to "DEBUG" and then check again. In the meantime here is the SonarQube Version: 10.0.0.68432 we are using.

@Nothing4You
Copy link

in my testing, against the same server i've been able to turn the 502 into a 401 (i don't have access to the api token) by bumping go-retryablehttp to v0.7.4, which was released about an hour ago, containing hashicorp/go-retryablehttp#194.

based on the description this is supposed to only affect PUT/POST, but i've been able to reproduce the 502 responses to GET requests from the server with go outside of this provider using go-retryablehttp v0.7.2/v0.7.3 and no longer with v0.7.4.

2023-06-06T22:04:36.664+0200 [DEBUG] provider.terraform-provider-sonarqube_v0.16.9: 2023/06/06 22:04:36 [DEBUG] GET https://dummy:@<sonarqube-fqdn>/api/system/info?
2023-06-06T22:04:36.778+0200 [ERROR] provider.terraform-provider-sonarqube_v0.16.9: Response contains error diagnostic: tf_provider_addr=registry.terraform.io/jdamata/sonarqube tf_req_id=fd3ff7f8-b00c-39a5-8769-804e29705b02 tf_rpc=Configure diagnostic_detail= diagnostic_severity=ERROR tf_proto_version=5.3 @module=sdk.proto diagnostic_summary="failed to decode error response json into struct: EOF" @caller=/home/tempuser/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/diag/diagnostics.go:55 timestamp=2023-06-06T22:04:36.778+0200
2023-06-06T22:04:36.779+0200 [ERROR] vertex "provider[\"dev.local/jdamata/sonarqube\"]" error: failed to decode error response json into struct: EOF
2023-06-06T22:04:36.779+0200 [INFO]  backend/local: plan operation completed

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: failed to decode error response json into struct: EOF
│
│   with provider["dev.local/jdamata/sonarqube"],
│   on main.tf line 11, in provider "sonarqube":
│   11: provider "sonarqube" {
$ git diff --patch-with-stat
 go.mod | 2 +-
 go.sum | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/go.mod b/go.mod
index 60f5897..0095234 100644
--- a/go.mod
+++ b/go.mod
@@ -4,7 +4,7 @@ go 1.18

 require (
        github.com/hashicorp/go-cleanhttp v0.5.2
-       github.com/hashicorp/go-retryablehttp v0.7.2
+       github.com/hashicorp/go-retryablehttp v0.7.4
        github.com/hashicorp/go-version v1.6.0
        github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1
        github.com/satori/uuid v1.2.0
diff --git a/go.sum b/go.sum
index d240ad9..a0f55e0 100644
--- a/go.sum
+++ b/go.sum
@@ -74,6 +74,8 @@ github.com/hashicorp/go-plugin v1.4.8 h1:CHGwpxYDOttQOY7HOWgETU9dyVjOXzniXDqJcYJ
 github.com/hashicorp/go-plugin v1.4.8/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s=
 github.com/hashicorp/go-retryablehttp v0.7.2 h1:AcYqCvkpalPnPF2pn0KamgwamS42TqUDDYFRKq/RAd0=
 github.com/hashicorp/go-retryablehttp v0.7.2/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
+github.com/hashicorp/go-retryablehttp v0.7.4 h1:ZQgVdpTdAL7WpMIwLzCfbalOcSUdkDZnpUv3/+BxzFA=
+github.com/hashicorp/go-retryablehttp v0.7.4/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
 github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
 github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
 github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=

@jdamata
Copy link
Owner

jdamata commented Jun 6, 2023

@Nothing4You odd issue and thanks for your investigative work. Did you want to open a pr to bump that dependency? I'm good with updating it as long as CI tests pass.

@jdamata
Copy link
Owner

jdamata commented Jun 7, 2023

Dependabot has done it for us #175

I'll cut a new release right now. Let me know if that works

@arogic
Copy link
Author

arogic commented Jun 7, 2023

Hi, I can confirm that the Issue has been fixed with terraform sonarqube provider version 1.16.2. Thank you @Nothing4You for your investigation and Thanks to @jdamata for your help. I guess this Issue can be closed. Regards

@jdamata jdamata closed this as completed Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants