aboutsummaryrefslogtreecommitdiff
path: root/plugin/file/reload.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2019-07-04 06:56:37 +0100
committerGravatar Yong Tang <yong.tang.github@outlook.com> 2019-07-04 13:56:37 +0800
commit18304ce9b75a401ed510d270c013dc4fe6480420 (patch)
tree089fc37b837831cd06c8012d922b94033ce21d64 /plugin/file/reload.go
parentf9fb9db1715e074c7549548e72f1d29d5ddc268f (diff)
downloadcoredns-18304ce9b75a401ed510d270c013dc4fe6480420.tar.gz
coredns-18304ce9b75a401ed510d270c013dc4fe6480420.tar.zst
coredns-18304ce9b75a401ed510d270c013dc4fe6480420.zip
plugin/file: make non-existent file non-fatal (#2955)
* plugin/file: make non-existent file non-fatal If the zone file being loaded doesn't exist *and* reload is enabled, just wait the file to pop up in the normal Reload routine. If reload is set to 0s; we keep this a fatal error on startup. Aslo fix the ticker in z.Reload(): remove the per second ticks and just use the reload interval for the ticker. Brush up the documentation a bit as well. Fixes: #2951 Signed-off-by: Miek Gieben <miek@miek.nl> * Stickler and test compile Signed-off-by: Miek Gieben <miek@miek.nl> * Remove there too Signed-off-by: Miek Gieben <miek@miek.nl> * Cant README test these because zone files dont exist Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/file/reload.go')
-rw-r--r--plugin/file/reload.go12
1 files changed, 1 insertions, 11 deletions
diff --git a/plugin/file/reload.go b/plugin/file/reload.go
index e73c5b87d..ce5c81335 100644
--- a/plugin/file/reload.go
+++ b/plugin/file/reload.go
@@ -5,15 +5,12 @@ import (
"time"
)
-// TickTime is clock resolution. By default ticks every second. Handler checks if reloadInterval has been reached on every tick.
-var TickTime = 1 * time.Second
-
// Reload reloads a zone when it is changed on disk. If z.NoReload is true, no reloading will be done.
func (z *Zone) Reload() error {
if z.ReloadInterval == 0 {
return nil
}
- tick := time.NewTicker(TickTime)
+ tick := time.NewTicker(z.ReloadInterval)
go func() {
@@ -21,13 +18,6 @@ func (z *Zone) Reload() error {
select {
case <-tick.C:
- if z.LastReloaded.Add(z.ReloadInterval).After(time.Now()) {
- //reload interval not reached yet
- continue
- }
- //saving timestamp of last attempted reload
- z.LastReloaded = time.Now()
-
zFile := z.File()
reader, err := os.Open(zFile)
if err != nil {