Merge pull request #2203 from justinsb/dnscontroller_fixes

dns-controller: skip over duplicate records
This commit is contained in:
Chris Love 2017-03-28 16:27:39 -06:00 committed by GitHub
commit dec92f531a
2 changed files with 23 additions and 1 deletions

View File

@ -43,6 +43,9 @@ var (
func main() {
fmt.Printf("dns-controller version %s\n", BuildVersion)
// Be sure to get the glog flags
glog.Flush()
dnsProviderId := "aws-route53"
flags.StringVar(&dnsProviderId, "dns", dnsProviderId, "DNS provider we should use (aws-route53, google-clouddns)")
@ -57,6 +60,8 @@ func main() {
flag.Set("logtostderr", "true")
flags.AddGoFlagSet(flag.CommandLine)
flags.Parse(os.Args)
zoneRules, err := dns.ParseZoneRules(zones)

View File

@ -256,7 +256,24 @@ func (c *DNSController) runOnce() error {
glog.V(4).Infof("updating records for %s: %v -> %v", k, oldValues, newValues)
err := op.updateRecords(k, newValues, int64(ttl.Seconds()))
// Duplicate records are a hard-error on e.g. Route53
var dedup []string
for _, s := range newValues {
alreadyExists := false
for _, e := range dedup {
if e == s {
alreadyExists = true
break
}
}
if alreadyExists {
glog.V(2).Infof("skipping duplicate record %s", s)
continue
}
dedup = append(dedup, s)
}
err := op.updateRecords(k, dedup, int64(ttl.Seconds()))
if err != nil {
glog.Infof("error updating records for %s: %v", k, err)
errors = append(errors, err)