Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.

Commit

Permalink
Fixed route53 dns ttl bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rancher-sy-bot committed Jun 14, 2019
1 parent 9b86cfe commit b8d4172
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions backend/route53/route53.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
maxSlugHashTimes = 100
slugLength = 6
tokenLength = 32
route53TTL = 300
)

type Backend struct {
Expand Down Expand Up @@ -157,7 +158,7 @@ func (b *Backend) Set(opts *model.DomainOptions) (d model.Domain, err error) {
Type: aws.String(typeA),
Name: aws.String(opts.Fqdn),
ResourceRecords: rr,
TTL: aws.Int64(int64(b.TTL.Seconds())),
TTL: aws.Int64(int64(route53TTL)),
}
pID, err := b.setRecord(rrs, opts, typeA, tID, 0, false)
if err != nil {
Expand All @@ -183,7 +184,7 @@ func (b *Backend) Set(opts *model.DomainOptions) (d model.Domain, err error) {
Type: aws.String(typeA),
Name: aws.String(fmt.Sprintf("%s.%s", k, opts.Fqdn)),
ResourceRecords: rr,
TTL: aws.Int64(int64(b.TTL.Seconds())),
TTL: aws.Int64(int64(route53TTL)),
}

if _, err := b.setRecord(rrs, opts, typeA, tID, pID, true); err != nil {
Expand Down Expand Up @@ -222,7 +223,7 @@ func (b *Backend) Update(opts *model.DomainOptions) (d model.Domain, err error)
Type: aws.String(typeA),
Name: aws.String(opts.Fqdn),
ResourceRecords: rr,
TTL: aws.Int64(int64(b.TTL.Seconds())),
TTL: aws.Int64(int64(route53TTL)),
}

r, err := database.GetDatabase().QueryA(opts.Fqdn)
Expand Down Expand Up @@ -253,7 +254,7 @@ func (b *Backend) Update(opts *model.DomainOptions) (d model.Domain, err error)
Type: aws.String(typeA),
Name: aws.String(fmt.Sprintf("%s.%s", k, opts.Fqdn)),
ResourceRecords: rr,
TTL: aws.Int64(int64(b.TTL.Seconds())),
TTL: aws.Int64(int64(route53TTL)),
}

if _, err := b.setRecord(rrs, opts, typeA, r.TID, r.ID, true); err != nil {
Expand All @@ -276,7 +277,7 @@ func (b *Backend) Update(opts *model.DomainOptions) (d model.Domain, err error)
Name: aws.String(fmt.Sprintf("%s.%s", k, opts.Fqdn)),
Type: aws.String(typeA),
ResourceRecords: rr,
TTL: aws.Int64(int64(b.TTL.Seconds())),
TTL: aws.Int64(int64(route53TTL)),
}

if err := b.deleteRecord(rrs, opts, typeA, true); err != nil {
Expand Down Expand Up @@ -411,7 +412,7 @@ func (b *Backend) SetText(opts *model.DomainOptions) (d model.Domain, err error)
Value: aws.String(fmt.Sprintf("\"%s\"", opts.Text)),
},
},
TTL: aws.Int64(int64(b.TTL.Seconds())),
TTL: aws.Int64(int64(route53TTL)),
}

if _, err := b.setRecord(rrs, opts, typeTXT, r.ID, 0, false); err != nil {
Expand Down Expand Up @@ -446,7 +447,7 @@ func (b *Backend) UpdateText(opts *model.DomainOptions) (d model.Domain, err err
Value: aws.String(fmt.Sprintf("\"%s\"", opts.Text)),
},
},
TTL: aws.Int64(int64(b.TTL.Seconds())),
TTL: aws.Int64(int64(route53TTL)),
}

if _, err := b.setRecord(rrs, opts, typeTXT, r.TID, 0, false); err != nil {
Expand Down Expand Up @@ -547,7 +548,7 @@ func (b *Backend) MigrateRecord(opts *model.MigrateRecord) error {
Type: aws.String(typeA),
Name: aws.String(dopts.Fqdn),
ResourceRecords: rr,
TTL: aws.Int64(int64(b.TTL.Seconds())),
TTL: aws.Int64(int64(route53TTL)),
}
pID, err := b.setRecord(rrs, dopts, typeA, t.ID, 0, false)
if err != nil {
Expand All @@ -573,7 +574,7 @@ func (b *Backend) MigrateRecord(opts *model.MigrateRecord) error {
Type: aws.String(typeA),
Name: aws.String(fmt.Sprintf("%s.%s", k, dopts.Fqdn)),
ResourceRecords: rr,
TTL: aws.Int64(int64(b.TTL.Seconds())),
TTL: aws.Int64(int64(route53TTL)),
}

if _, err := b.setRecord(rrs, dopts, typeA, t.ID, pID, true); err != nil {
Expand Down Expand Up @@ -723,7 +724,7 @@ func (b *Backend) deleteRecord(rrs *route53.ResourceRecordSet, opts *model.Domai
Name: rrs.Name,
Type: aws.String(rType),
ResourceRecords: rrs.ResourceRecords,
TTL: aws.Int64(int64(b.TTL.Seconds())),
TTL: aws.Int64(int64(route53TTL)),
},
},
},
Expand Down

0 comments on commit b8d4172

Please sign in to comment.