-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update rfc2136 provider to split out changes per zone #4107
Changes from 6 commits
e44aa65
e3b8e54
1418a3a
7427c8e
35dc1fc
2b4aa56
8e9a416
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -256,7 +256,12 @@ func (r rfc2136Provider) ApplyChanges(ctx context.Context, changes *plan.Changes | |||||||
for c, chunk := range chunkBy(changes.Create, r.batchChangeSize) { | ||||||||
log.Debugf("Processing batch %d of create changes", c) | ||||||||
|
||||||||
m := new(dns.Msg) | ||||||||
m := make(map[string]*dns.Msg) | ||||||||
m["."] = new(dns.Msg) // Add the root zone | ||||||||
for _, z := range r.zoneNames { | ||||||||
z = dns.Fqdn(z) | ||||||||
m[z] = new(dns.Msg) | ||||||||
} | ||||||||
for _, ep := range chunk { | ||||||||
if !r.domainFilter.Match(ep.DNSName) { | ||||||||
log.Debugf("Skipping record %s because it was filtered out by the specified --domain-filter", ep.DNSName) | ||||||||
|
@@ -265,26 +270,33 @@ func (r rfc2136Provider) ApplyChanges(ctx context.Context, changes *plan.Changes | |||||||
|
||||||||
zone := findMsgZone(ep, r.zoneNames) | ||||||||
r.krb5Realm = strings.ToUpper(zone) | ||||||||
m.SetUpdate(zone) | ||||||||
m[zone].SetUpdate(zone) | ||||||||
|
||||||||
r.AddRecord(m, ep) | ||||||||
r.AddRecord(m[zone], ep) | ||||||||
} | ||||||||
|
||||||||
// only send if there are records available | ||||||||
if len(m.Ns) > 0 { | ||||||||
err := r.actions.SendMessage(m) | ||||||||
if err != nil { | ||||||||
log.Errorf("RFC2136 update failed: %v", err) | ||||||||
errors = append(errors, err) | ||||||||
continue | ||||||||
for _, z := range m { | ||||||||
if len(z.Ns) > 0 { | ||||||||
err := r.actions.SendMessage(z) | ||||||||
if err != nil { | ||||||||
log.Errorf("RFC2136 update failed: %v", err) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
errors = append(errors, err) | ||||||||
continue | ||||||||
} | ||||||||
} | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
for c, chunk := range chunkBy(changes.UpdateNew, r.batchChangeSize) { | ||||||||
log.Debugf("Processing batch %d of update changes", c) | ||||||||
|
||||||||
m := new(dns.Msg) | ||||||||
m := make(map[string]*dns.Msg) | ||||||||
m["."] = new(dns.Msg) // Add the root zone | ||||||||
for _, z := range r.zoneNames { | ||||||||
z = dns.Fqdn(z) | ||||||||
m[z] = new(dns.Msg) | ||||||||
} | ||||||||
|
||||||||
for i, ep := range chunk { | ||||||||
if !r.domainFilter.Match(ep.DNSName) { | ||||||||
|
@@ -294,27 +306,33 @@ func (r rfc2136Provider) ApplyChanges(ctx context.Context, changes *plan.Changes | |||||||
|
||||||||
zone := findMsgZone(ep, r.zoneNames) | ||||||||
r.krb5Realm = strings.ToUpper(zone) | ||||||||
m.SetUpdate(zone) | ||||||||
m[zone].SetUpdate(zone) | ||||||||
|
||||||||
r.UpdateRecord(m, changes.UpdateOld[i], ep) | ||||||||
r.UpdateRecord(m[zone], changes.UpdateOld[i], ep) | ||||||||
} | ||||||||
|
||||||||
// only send if there are records available | ||||||||
if len(m.Ns) > 0 { | ||||||||
err := r.actions.SendMessage(m) | ||||||||
if err != nil { | ||||||||
log.Errorf("RFC2136 update failed: %v", err) | ||||||||
errors = append(errors, err) | ||||||||
continue | ||||||||
for _, z := range m { | ||||||||
if len(z.Ns) > 0 { | ||||||||
err := r.actions.SendMessage(z) | ||||||||
if err != nil { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
log.Errorf("RFC2136 update failed: %v", err) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
errors = append(errors, err) | ||||||||
continue | ||||||||
} | ||||||||
} | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
for c, chunk := range chunkBy(changes.Delete, r.batchChangeSize) { | ||||||||
log.Debugf("Processing batch %d of delete changes", c) | ||||||||
|
||||||||
m := new(dns.Msg) | ||||||||
|
||||||||
m := make(map[string]*dns.Msg) | ||||||||
m["."] = new(dns.Msg) // Add the root zone | ||||||||
for _, z := range r.zoneNames { | ||||||||
z = dns.Fqdn(z) | ||||||||
m[z] = new(dns.Msg) | ||||||||
} | ||||||||
for _, ep := range chunk { | ||||||||
if !r.domainFilter.Match(ep.DNSName) { | ||||||||
log.Debugf("Skipping record %s because it was filtered out by the specified --domain-filter", ep.DNSName) | ||||||||
|
@@ -323,18 +341,20 @@ func (r rfc2136Provider) ApplyChanges(ctx context.Context, changes *plan.Changes | |||||||
|
||||||||
zone := findMsgZone(ep, r.zoneNames) | ||||||||
r.krb5Realm = strings.ToUpper(zone) | ||||||||
m.SetUpdate(zone) | ||||||||
m[zone].SetUpdate(zone) | ||||||||
|
||||||||
r.RemoveRecord(m, ep) | ||||||||
r.RemoveRecord(m[zone], ep) | ||||||||
} | ||||||||
|
||||||||
// only send if there are records available | ||||||||
if len(m.Ns) > 0 { | ||||||||
err := r.actions.SendMessage(m) | ||||||||
if err != nil { | ||||||||
log.Errorf("RFC2136 update failed: %v", err) | ||||||||
errors = append(errors, err) | ||||||||
continue | ||||||||
for _, z := range m { | ||||||||
if len(z.Ns) > 0 { | ||||||||
err := r.actions.SendMessage(z) | ||||||||
if err != nil { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
log.Errorf("RFC2136 update failed: %v", err) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
errors = append(errors, err) | ||||||||
continue | ||||||||
} | ||||||||
} | ||||||||
} | ||||||||
} | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.