Revert "Implement notifies for transfer plugin (#3972)" (#3995)

This reverts commit 68f1dd5ddf.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
Yong Tang
2020-07-08 09:00:26 -07:00
committed by GitHub
parent 68f1dd5ddf
commit 614d08cba2
42 changed files with 988 additions and 707 deletions

View File

@@ -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...)
}
}
}
}