mirror of
https://github.com/coredns/coredns.git
synced 2025-09-21 13:41:15 +02:00
plugin/etcd: fix etcd connection leakage when reload (#6646)
Signed-off-by: zhongyuanjun <zhongyuanjun@bytedance.com> Co-authored-by: zhongyuanjun <zhongyuanjun@bytedance.com>
This commit is contained in:
parent
ebbbb453be
commit
ee4d26b780
@ -183,3 +183,11 @@ func (e *Etcd) TTL(kv *mvccpb.KeyValue, serv *msg.Service) uint32 {
|
||||
func shouldInclude(serv *msg.Service, qType uint16) bool {
|
||||
return (qType == dns.TypeTXT && serv.Text != "") || serv.Host != ""
|
||||
}
|
||||
|
||||
// OnShutdown shuts down etcd client when caddy instance restart
|
||||
func (e *Etcd) OnShutdown() error {
|
||||
if e.Client != nil {
|
||||
e.Client.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ func setup(c *caddy.Controller) error {
|
||||
return plugin.Error("etcd", err)
|
||||
}
|
||||
|
||||
c.OnShutdown(e.OnShutdown)
|
||||
|
||||
dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
|
||||
e.Next = next
|
||||
return e
|
||||
|
Loading…
x
Reference in New Issue
Block a user