try DefaultTTL

This commit is contained in:
Thomas Limoncelli 2025-12-03 15:26:09 -05:00
parent b613a13183
commit 46c4ec431e
No known key found for this signature in database
3 changed files with 10 additions and 6 deletions

View file

@ -6,11 +6,14 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/providers" "github.com/StackExchange/dnscontrol/v4/providers"
_ "github.com/StackExchange/dnscontrol/v4/providers/_all" _ "github.com/StackExchange/dnscontrol/v4/providers/_all"
) )
func TestDNSProviders(t *testing.T) { func TestDNSProviders(t *testing.T) {
models.DefaultTTL = 600 // Avoid problems due to minimum TTLs
provider, domain, cfg := getProvider(t) provider, domain, cfg := getProvider(t)
if provider == nil { if provider == nil {
return return
@ -223,10 +226,11 @@ func makeTests() []*TestGroup {
testgroup("TTL", testgroup("TTL",
not("NETCUP"), // NETCUP does not support TTLs. not("NETCUP"), // NETCUP does not support TTLs.
not("LINODE"), // Linode does not support arbitrary TTLs: 666 and 1000 are both rounded up to 3600. not("LINODE"), // Linode does not support arbitrary TTLs: 666 and 1000 are both rounded up to 3600.
tc("Start", ttl(a("@", "8.8.8.8"), 900), ttl(a("www", "1.2.3.4"), 800), ttl(a("www", "5.6.7.8"), 700)), // NOTE: Many providers require all records in a recordset have the same TTL. Don't add tests that break that rule.
tc("Change a ttl", ttl(a("@", "8.8.8.8"), 911), ttl(a("www", "1.2.3.4"), 800), ttl(a("www", "5.6.7.8"), 700)), tc("Start ", ttl(a("@", "8.8.8.8"), 600), ttl(a("www", "1.2.3.4"), 600), ttl(a("www", "5.6.7.8"), 600)),
tc("Change single ttl in set", ttl(a("@", "8.8.8.8"), 911), ttl(a("www", "1.2.3.4"), 822), ttl(a("www", "5.6.7.8"), 700)), tc("Change a ttl ", ttl(a("@", "8.8.8.8"), 700), ttl(a("www", "1.2.3.4"), 600), ttl(a("www", "5.6.7.8"), 600)),
tc("Change all ttls", ttl(a("@", "8.8.8.8"), 933), ttl(a("www", "2.2.2.2"), 933), ttl(a("www", "5.6.7.8"), 933)), tc("Change others ", ttl(a("@", "8.8.8.8"), 700), ttl(a("www", "2.2.2.2"), 800), ttl(a("www", "5.6.7.8"), 800)),
tc("Change all ttls", ttl(a("@", "8.8.8.8"), 900), ttl(a("www", "2.2.2.2"), 900), ttl(a("www", "5.6.7.8"), 900)),
), ),
// Narrative: Did you see that `not("NETCUP")` code? NETCUP just // Narrative: Did you see that `not("NETCUP")` code? NETCUP just

View file

@ -8,7 +8,7 @@ import (
) )
// DefaultTTL is applied to any DNS record without an explicit TTL. // DefaultTTL is applied to any DNS record without an explicit TTL.
const DefaultTTL = uint32(300) var DefaultTTL = uint32(300)
// DNSConfig describes the desired DNS configuration, usually loaded from dnsconfig.js. // DNSConfig describes the desired DNS configuration, usually loaded from dnsconfig.js.
type DNSConfig struct { type DNSConfig struct {

View file

@ -442,7 +442,7 @@ func nativeToRecords(set r53Types.ResourceRecordSet, origin string) ([]*models.R
if set.AliasTarget != nil { if set.AliasTarget != nil {
rc := &models.RecordConfig{ rc := &models.RecordConfig{
Type: "R53_ALIAS", Type: "R53_ALIAS",
TTL: 300, TTL: models.DefaultTTL,
R53Alias: map[string]string{ R53Alias: map[string]string{
"type": string(set.Type), "type": string(set.Type),
"zone_id": aws.ToString(set.AliasTarget.HostedZoneId), "zone_id": aws.ToString(set.AliasTarget.HostedZoneId),