mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 00:04:15 -04:00
send notifies after adding zones all zones (#5774)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user