send notifies after adding zones all zones (#5774)

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
Chris O'Haver
2023-02-15 13:25:02 -05:00
committed by GitHub
parent ad623eb0d6
commit 77c7c0b4cb
4 changed files with 21 additions and 5 deletions

View File

@@ -45,6 +45,9 @@ func setup(c *caddy.Controller) error {
if err != nil {
return err
}
if err := a.Notify(); err != nil {
log.Warning(err)
}
if a.loader.ReloadInterval == 0 {
return nil
}
@@ -57,6 +60,9 @@ func setup(c *caddy.Controller) error {
return
case <-ticker.C:
a.Walk()
if err := a.Notify(); err != nil {
log.Warning(err)
}
}
}
}()

View File

@@ -59,8 +59,6 @@ func (a Auto) Walk() error {
a.metrics.AddZone(origin)
}
a.transfer.Notify(origin)
log.Infof("Inserting zone `%s' from: %s", origin, path)
toDelete[origin] = false

View File

@@ -17,3 +17,15 @@ func (a Auto) Transfer(zone string, serial uint32) (<-chan []dns.RR, error) {
}
return z.Transfer(serial)
}
// Notify sends notifies for all zones with secondaries configured with the transfer plugin
func (a Auto) Notify() error {
var err error
for _, origin := range a.Zones.Names() {
e := a.transfer.Notify(origin)
if e != nil {
err = e
}
}
return err
}

View File

@@ -8,8 +8,7 @@ import (
"github.com/miekg/dns"
)
// Notify will send notifies to all configured to hosts IP addresses. If the zone isn't known
// to t an error will be returned. The string zone must be lowercased.
// Notify will send notifies to all configured to hosts IP addresses. The string zone must be lowercased.
func (t *Transfer) Notify(zone string) error {
if t == nil { // t might be nil, mostly expected in tests, so intercept and to a noop in that case
return nil
@@ -21,7 +20,8 @@ func (t *Transfer) Notify(zone string) error {
x := longestMatch(t.xfrs, zone)
if x == nil {
return fmt.Errorf("no such zone registred in the transfer plugin: %s", zone)
// return without error if there is no matching zone
return nil
}
var err1 error