diff options
author | 2023-02-15 13:25:02 -0500 | |
---|---|---|
committer | 2023-02-15 13:25:02 -0500 | |
commit | 77c7c0b4cb20d51b81a5fc351e3d39414ec18cc9 (patch) | |
tree | 0c503110e6e79d53c823793ceb3dc36fc482e92b | |
parent | ad623eb0d6577355eab78bd9c0fb4755d427b0af (diff) | |
download | coredns-77c7c0b4cb20d51b81a5fc351e3d39414ec18cc9.tar.gz coredns-77c7c0b4cb20d51b81a5fc351e3d39414ec18cc9.tar.zst coredns-77c7c0b4cb20d51b81a5fc351e3d39414ec18cc9.zip |
send notifies after adding zones all zones (#5774)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
-rw-r--r-- | plugin/auto/setup.go | 6 | ||||
-rw-r--r-- | plugin/auto/walk.go | 2 | ||||
-rw-r--r-- | plugin/auto/xfr.go | 12 | ||||
-rw-r--r-- | plugin/transfer/notify.go | 6 |
4 files changed, 21 insertions, 5 deletions
diff --git a/plugin/auto/setup.go b/plugin/auto/setup.go index 1a7eee980..bd9479767 100644 --- a/plugin/auto/setup.go +++ b/plugin/auto/setup.go @@ -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) + } } } }() diff --git a/plugin/auto/walk.go b/plugin/auto/walk.go index a50c5d85c..c7dd4e9c9 100644 --- a/plugin/auto/walk.go +++ b/plugin/auto/walk.go @@ -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 diff --git a/plugin/auto/xfr.go b/plugin/auto/xfr.go index 6fef8b9e8..828a58cfa 100644 --- a/plugin/auto/xfr.go +++ b/plugin/auto/xfr.go @@ -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 +}
\ No newline at end of file diff --git a/plugin/transfer/notify.go b/plugin/transfer/notify.go index b024a3aa1..26f766868 100644 --- a/plugin/transfer/notify.go +++ b/plugin/transfer/notify.go @@ -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 |