linodev4: configurable propagation timeout. (#961)

This commit is contained in:
Ludovic Fernandez 2019-09-17 21:25:59 +02:00 committed by GitHub
parent d7d75bea51
commit 6bbba5bbaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 19 deletions

View file

@ -833,6 +833,7 @@ func displayDNSHelp(name string) error {
ew.writeln(`Additional Configuration:`) ew.writeln(`Additional Configuration:`)
ew.writeln(` - "LINODE_HTTP_TIMEOUT": API request timeout`) ew.writeln(` - "LINODE_HTTP_TIMEOUT": API request timeout`)
ew.writeln(` - "LINODE_POLLING_INTERVAL": Time between DNS propagation check`) ew.writeln(` - "LINODE_POLLING_INTERVAL": Time between DNS propagation check`)
ew.writeln(` - "LINODE_PROPAGATION_TIMEOUT": Maximum waiting time for DNS propagation`)
ew.writeln(` - "LINODE_TTL": The TTL of the TXT record used for the DNS challenge`) ew.writeln(` - "LINODE_TTL": The TTL of the TXT record used for the DNS challenge`)
ew.writeln() ew.writeln()

View file

@ -41,6 +41,7 @@ More information [here](/lego/dns/#configuration-and-credentials).
|--------------------------------|-------------| |--------------------------------|-------------|
| `LINODE_HTTP_TIMEOUT` | API request timeout | | `LINODE_HTTP_TIMEOUT` | API request timeout |
| `LINODE_POLLING_INTERVAL` | Time between DNS propagation check | | `LINODE_POLLING_INTERVAL` | Time between DNS propagation check |
| `LINODE_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation |
| `LINODE_TTL` | The TTL of the TXT record used for the DNS challenge | | `LINODE_TTL` | The TTL of the TXT record used for the DNS challenge |
The environment variable names can be suffixed by `_FILE` to reference a file instead of a value. The environment variable names can be suffixed by `_FILE` to reference a file instead of a value.

View file

@ -25,6 +25,7 @@ const (
// Config is used to configure the creation of the DNSProvider // Config is used to configure the creation of the DNSProvider
type Config struct { type Config struct {
Token string Token string
PropagationTimeout time.Duration
PollingInterval time.Duration PollingInterval time.Duration
TTL int TTL int
HTTPTimeout time.Duration HTTPTimeout time.Duration
@ -33,6 +34,7 @@ type Config struct {
// NewDefaultConfig returns a default configuration for the DNSProvider // NewDefaultConfig returns a default configuration for the DNSProvider
func NewDefaultConfig() *Config { func NewDefaultConfig() *Config {
return &Config{ return &Config{
PropagationTimeout: env.GetOrDefaultSecond("LINODE_PROPAGATION_TIMEOUT", 0),
PollingInterval: env.GetOrDefaultSecond("LINODE_POLLING_INTERVAL", 15*time.Second), PollingInterval: env.GetOrDefaultSecond("LINODE_POLLING_INTERVAL", 15*time.Second),
TTL: env.GetOrDefaultInt("LINODE_TTL", minTTL), TTL: env.GetOrDefaultInt("LINODE_TTL", minTTL),
HTTPTimeout: env.GetOrDefaultSecond("LINODE_HTTP_TIMEOUT", 0), HTTPTimeout: env.GetOrDefaultSecond("LINODE_HTTP_TIMEOUT", 0),
@ -97,7 +99,9 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
// Timeout returns the timeout and interval to use when checking for DNS // Timeout returns the timeout and interval to use when checking for DNS
// propagation. Adjusting here to cope with spikes in propagation times. // propagation. Adjusting here to cope with spikes in propagation times.
func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { func (d *DNSProvider) Timeout() (time.Duration, time.Duration) {
timeout := d.config.PropagationTimeout
if d.config.PropagationTimeout <= 0 {
// Since Linode only updates their zone files every X minutes, we need // Since Linode only updates their zone files every X minutes, we need
// to figure out how many minutes we have to wait until we hit the next // to figure out how many minutes we have to wait until we hit the next
// interval of X. We then wait another couple of minutes, just to be // interval of X. We then wait another couple of minutes, just to be
@ -108,8 +112,9 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
timeout = (time.Duration(minsRemaining) * time.Minute) + timeout = (time.Duration(minsRemaining) * time.Minute) +
(minTTL * time.Second) + (minTTL * time.Second) +
(dnsUpdateFudgeSecs * time.Second) (dnsUpdateFudgeSecs * time.Second)
interval = d.config.PollingInterval }
return
return timeout, d.config.PollingInterval
} }
// Present creates a TXT record using the specified parameters. // Present creates a TXT record using the specified parameters.

View file

@ -11,6 +11,7 @@ Example = ''''''
LINODE_TOKEN = "API token" LINODE_TOKEN = "API token"
[Configuration.Additional] [Configuration.Additional]
LINODE_POLLING_INTERVAL = "Time between DNS propagation check" LINODE_POLLING_INTERVAL = "Time between DNS propagation check"
LINODE_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation"
LINODE_TTL = "The TTL of the TXT record used for the DNS challenge" LINODE_TTL = "The TTL of the TXT record used for the DNS challenge"
LINODE_HTTP_TIMEOUT = "API request timeout" LINODE_HTTP_TIMEOUT = "API request timeout"