go-gandi / terraform-provider-gandi

Terraform provider for the Gandi Domain services
Mozilla Public License 2.0
152 stars 47 forks source link

New livedns record: context deadline exceeded #145

Open dan-mcdonald opened 1 year ago

dan-mcdonald commented 1 year ago

I'm trying to add a new A record to my Gandi LiveDNS with this provider.

resource "gandi_livedns_record" "agency" {
  name = "agency"
  ttl = 300
  type = "A"
  values = [aws_instance.agency.public_ip]
  zone = "▮▮▮▮▮.net"
}

But during apply I get this error (run with TF_LOG=INFO):

gandi_livedns_record.agency: Creating...
2023-07-05T10:44:10.239-0500 [INFO]  Starting apply for gandi_livedns_record.agency
2023-07-05T10:44:18.053-0500 [ERROR] vertex "gandi_livedns_record.agency" error: Fail to do the request (error 'Get "https://api.gandi.net/v5/livedns/domains/▮▮▮▮▮.net/records/agency/A": context deadline exceeded (Client.Timeout exceeded while awaiting headers)')
╷
│ Error: Fail to do the request (error 'Get "https://api.gandi.net/v5/livedns/domains/▮▮▮▮▮.net/records/agency/A": context deadline exceeded (Client.Timeout exceeded while awaiting headers)')
│
│   with gandi_livedns_record.agency,
│   on main.tf line 36, in resource "gandi_livedns_record" "agency":
│   36: resource "gandi_livedns_record" "agency" {
│

I think the request will work if it is given more time. My internet connection is not the fastest. Is there a configuration knob to increase the timeout? Currently it fails for me after only 10/15 seconds.

Other details:

> terraform version 
2023-07-05T10:48:33.039-0500 [INFO]  Terraform version: 1.5.2
2023-07-05T10:48:33.041-0500 [INFO]  Go runtime version: go1.20
2023-07-05T10:48:33.042-0500 [INFO]  CLI args: []string{"C:\\Users\\danie_10m7rom\\dev\\bin\\terraform.exe", "version"}
2023-07-05T10:48:33.062-0500 [INFO]  CLI command args: []string{"version"}
Terraform v1.5.2
on windows_amd64
+ provider registry.terraform.io/go-gandi/gandi v2.2.3
+ provider registry.terraform.io/hashicorp/aws v5.6.1

Any help you provide is appreciated. I know I'm not entitled to any free help.

benbouillet commented 4 months ago

I'm getting this issue intermittently, did you find a workaround ? @dan-mcdonald

marcaurele commented 3 months ago

We do have the same problem and it appears quite often on our plan execution, which is very problematic for us. I'm surprised to read from the API documentation^1:

Rate limit

Gandi's API is rate limited; you can perform a maximum of 1000 requests per minute from the same IP address.

which we are definitively not hitting.

Moreover, looking at the code / reference there is a (strange) custom default key to configure the timeout for the nemserver records: https://registry.terraform.io/providers/go-gandi/gandi/latest/docs/resources/nameservers#default

Adding this block in the resource did not even fix the problem:

resource "gandi_nameservers" "example" {
  ...
  timeouts {
    default = 60
  }
}

[!NOTE] The provider code has some code for a default timeout, which is not exposed in the provider configuration, with a default value of 5 seconds.

:shrug:

insertjokehere commented 3 months ago

I'm running into this essentially every time I run terraform plan, which is very frustrating.

It seems like the plugin passes config back to the go-gandi library here:

https://github.com/go-gandi/terraform-provider-gandi/blob/c38a15f10015d5d14a8982ca334709e241092a93/gandi/provider.go#L84-L106

The library exposes a timeout option (defaulting to 5 seconds) which the terraform provider doesn't provide a way to override:

https://github.com/go-gandi/go-gandi/blob/29df69368462adc734b4ffc650d33918f11d25f4/config/config.go#L6-L31

Ideally Gandi would fix their API so it wasn't so slow, but as an interim solution it'd be nice to be able to override the timeout config

marcaurele commented 2 months ago

We solved it the hard way... moving away from Gandi.