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(` - "LINODE_HTTP_TIMEOUT": API request timeout`)
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()

View file

@ -41,6 +41,7 @@ More information [here](/lego/dns/#configuration-and-credentials).
|--------------------------------|-------------|
| `LINODE_HTTP_TIMEOUT` | API request timeout |
| `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 |
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
type Config struct {
Token string
PropagationTimeout time.Duration
PollingInterval time.Duration
TTL int
HTTPTimeout time.Duration
@ -33,6 +34,7 @@ type Config struct {
// NewDefaultConfig returns a default configuration for the DNSProvider
func NewDefaultConfig() *Config {
return &Config{
PropagationTimeout: env.GetOrDefaultSecond("LINODE_PROPAGATION_TIMEOUT", 0),
PollingInterval: env.GetOrDefaultSecond("LINODE_POLLING_INTERVAL", 15*time.Second),
TTL: env.GetOrDefaultInt("LINODE_TTL", minTTL),
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
// 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
// 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
@ -108,8 +112,9 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
timeout = (time.Duration(minsRemaining) * time.Minute) +
(minTTL * time.Second) +
(dnsUpdateFudgeSecs * time.Second)
interval = d.config.PollingInterval
return
}
return timeout, d.config.PollingInterval
}
// Present creates a TXT record using the specified parameters.

View file

@ -11,6 +11,7 @@ Example = ''''''
LINODE_TOKEN = "API token"
[Configuration.Additional]
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_HTTP_TIMEOUT = "API request timeout"