diff options
author | 2020-07-08 09:00:26 -0700 | |
---|---|---|
committer | 2020-07-08 09:00:26 -0700 | |
commit | 614d08cba29ed4904d11008e795c081c4f392b77 (patch) | |
tree | e4601abda23ec9d18e2929433c260a37928e1344 /plugin/file/setup.go | |
parent | 68f1dd5ddf0451cc3a1b24a72c2965b8d896ffba (diff) | |
download | coredns-614d08cba29ed4904d11008e795c081c4f392b77.tar.gz coredns-614d08cba29ed4904d11008e795c081c4f392b77.tar.zst coredns-614d08cba29ed4904d11008e795c081c4f392b77.zip |
Revert "Implement notifies for transfer plugin (#3972)" (#3995)
This reverts commit 68f1dd5ddf0451cc3a1b24a72c2965b8d896ffba.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Diffstat (limited to 'plugin/file/setup.go')
-rw-r--r-- | plugin/file/setup.go | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/plugin/file/setup.go b/plugin/file/setup.go index 1309dcf85..44ecf2ca1 100644 --- a/plugin/file/setup.go +++ b/plugin/file/setup.go @@ -7,8 +7,8 @@ import ( "github.com/coredns/coredns/core/dnsserver" "github.com/coredns/coredns/plugin" + "github.com/coredns/coredns/plugin/pkg/parse" "github.com/coredns/coredns/plugin/pkg/upstream" - "github.com/coredns/coredns/plugin/transfer" "github.com/caddyserver/caddy" ) @@ -21,43 +21,26 @@ func setup(c *caddy.Controller) error { return plugin.Error("file", err) } - f := File{Zones: zones} - // get the transfer plugin, so we can send notifies and send notifies on startup as well. - c.OnStartup(func() error { - t := dnsserver.GetConfig(c).Handler("transfer") - if t == nil { - return nil - } - f.transfer = t.(*transfer.Transfer) // if found this must be OK. - for _, n := range zones.Names { - f.transfer.Notify(n) - } - return nil - }) - - c.OnRestartFailed(func() error { - t := dnsserver.GetConfig(c).Handler("transfer") - if t == nil { - return nil - } - for _, n := range zones.Names { - f.transfer.Notify(n) - } - return nil - }) - + // Add startup functions to notify the master(s). for _, n := range zones.Names { z := zones.Z[n] - c.OnShutdown(z.OnShutdown) c.OnStartup(func() error { - z.StartupOnce.Do(func() { z.Reload(f.transfer) }) + z.StartupOnce.Do(func() { + if len(z.TransferTo) > 0 { + z.Notify() + } + z.Reload() + }) return nil }) } + for _, n := range zones.Names { + z := zones.Z[n] + c.OnShutdown(z.OnShutdown) + } dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler { - f.Next = next - return f + return File{Next: next, Zones: zones} }) return nil @@ -110,14 +93,24 @@ func fileParse(c *caddy.Controller) (Zones, error) { names = append(names, origins[i]) } + t := []string{} + var e error + for c.NextBlock() { switch c.Val() { + case "transfer": + t, _, e = parse.Transfer(c, false) + if e != nil { + return Zones{}, e + } + case "reload": d, err := time.ParseDuration(c.RemainingArgs()[0]) if err != nil { return Zones{}, plugin.Error("file", err) } reload = d + case "upstream": // remove soon c.RemainingArgs() @@ -125,6 +118,12 @@ func fileParse(c *caddy.Controller) (Zones, error) { default: return Zones{}, c.Errf("unknown property '%s'", c.Val()) } + + for _, origin := range origins { + if t != nil { + z[origin].TransferTo = append(z[origin].TransferTo, t...) + } + } } } |