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

@@ -16,6 +16,7 @@ zonefile. New or changed zones are automatically picked up from disk.
~~~
auto [ZONES...] {
directory DIR [REGEXP ORIGIN_TEMPLATE [TIMEOUT]]
reload DURATION
no_reload
upstream [ADDRESS...]
}
@@ -31,8 +32,10 @@ are used.
name `db.example.com`, the extracted origin will be `example.com`. **TIMEOUT** specifies how often
CoreDNS should scan the directory; the default is every 60 seconds. This value is in seconds.
The minimum value is 1 second.
* `no_reload` by default CoreDNS will try to reload a zone every minute and reloads if the
SOA's serial has changed. This option disables that behavior.
* `reload` interval to perform reload of zone if SOA version changes. Default is one minute.
Value of `0` means to not scan for changes and reload. eg. `30s` checks zonefile every 30 seconds
and reloads zone when serial changes.
* `no_reload` deprecated. Sets reload to 0.
* `upstream` defines upstream resolvers to be used resolve external names found (think CNAMEs)
pointing to external names. **ADDRESS** can be an IP address, an IP:port or a string pointing to
a file that is structured as /etc/resolv.conf. If no **ADDRESS** is given, CoreDNS will resolve CNAMEs

View File

@@ -32,7 +32,7 @@ type (
// In the future this should be something like ZoneMeta that contains all this stuff.
transferTo []string
noReload bool
ReloadInterval time.Duration
upstream upstream.Upstream // Upstream for looking up names during the resolution process.
duration time.Duration

View File

@@ -144,8 +144,15 @@ func autoParse(c *caddy.Controller) (Auto, error) {
a.loader.duration = time.Duration(i) * time.Second
}
case "reload":
d, err := time.ParseDuration(c.RemainingArgs()[0])
if err != nil {
return a, plugin.Error("file", err)
}
a.loader.ReloadInterval = d
case "no_reload":
a.loader.noReload = true
a.loader.ReloadInterval = 0
case "upstream":
args := c.RemainingArgs()

View File

@@ -52,7 +52,7 @@ func (a Auto) Walk() error {
return nil
}
zo.NoReload = a.loader.noReload
zo.ReloadInterval = a.loader.ReloadInterval
zo.Upstream = a.loader.upstream
zo.TransferTo = a.loader.transferTo