Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #3110 from mikesplain/FixWildcards
Automatic merge from submit-queue

Fix Wildcard domains returned as ASCII in dns-controller

After running into #2671 whenever dns-controller restarted, I looked into why dns-controller successfully creates entries for wildcard domains (e.g. `*.example.com` ) but after restarting, it errors, unable to find the old record.  It looks amazon returns ascii `\\052.example.com` instead of the `*.example.com` we expect. This was a simple fix I tested in our cluster and it seems to have fixed the issue.  I'm open to any changes but I think this could be a useful fix for those that may run into this in the future.

This isn't a new thing apparently: boto/boto#818

Fixes #2671
  • Loading branch information
Kubernetes Submit Queue committed Aug 2, 2017
2 parents 58e0074 + 84daad4 commit b40320a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dns-controller/pkg/dns/dnscontroller.go
Expand Up @@ -503,6 +503,10 @@ func isCoreDNSZone(zone dnsprovider.Zone) bool {
return ok
}

func FixWildcards(s string) string {
return strings.Replace(s, "\\052", "*", 1)
}

func (o *dnsOp) updateRecords(k recordKey, newRecords []string, ttl int64) error {
fqdn := EnsureDotSuffix(k.FQDN)

Expand Down Expand Up @@ -539,7 +543,7 @@ func (o *dnsOp) updateRecords(k recordKey, newRecords []string, ttl int64) error
}

for _, rr := range rrs {
rrName := EnsureDotSuffix(rr.Name())
rrName := EnsureDotSuffix(FixWildcards(rr.Name()))
if rrName != fqdn {
glog.V(8).Infof("Skipping record %q (name != %s)", rrName, fqdn)
continue
Expand All @@ -564,7 +568,7 @@ func (o *dnsOp) updateRecords(k recordKey, newRecords []string, ttl int64) error
}

if existing != nil {
glog.V(2).Infof("will replace existing dns record %s %s", existing.Type(), existing.Name())
glog.V(2).Infof("will replace existing dns record %s %s", existing.Type(), FixWildcards(existing.Name()))
cs.Remove(existing)
}

Expand Down

0 comments on commit b40320a

Please sign in to comment.