Configurable zone reload interval in file plugin (#2110)

* Configurable zone reload interval in file plugin

* passing reload config from auto plugin to file plugin. removed noReload property from Zone struct. fixed tests based on short file reload hack
This commit is contained in:
marqc
2018-09-29 17:50:49 +02:00
committed by Miek Gieben
parent a80ec6096f
commit 552aab723c
12 changed files with 53 additions and 20 deletions

View File

@@ -6,6 +6,7 @@ import (
"path"
"strings"
"sync"
"time"
"github.com/coredns/coredns/plugin/file/tree"
"github.com/coredns/coredns/plugin/pkg/upstream"
@@ -27,7 +28,8 @@ type Zone struct {
TransferFrom []string
Expired *bool
NoReload bool
ReloadInterval time.Duration
LastReloaded time.Time
reloadMu sync.RWMutex
reloadShutdown chan bool
Upstream upstream.Upstream // Upstream for looking up names during the resolution process
@@ -50,6 +52,7 @@ func NewZone(name, file string) *Zone {
Tree: &tree.Tree{},
Expired: new(bool),
reloadShutdown: make(chan bool),
LastReloaded: time.Now(),
}
*z.Expired = false
@@ -161,7 +164,7 @@ func (z *Zone) TransferAllowed(state request.Request) bool {
// All returns all records from the zone, the first record will be the SOA record,
// otionally followed by all RRSIG(SOA)s.
func (z *Zone) All() []dns.RR {
if !z.NoReload {
if z.ReloadInterval > 0 {
z.reloadMu.RLock()
defer z.reloadMu.RUnlock()
}