Fully deprecate TIMEOUT and NO_RELOAD (#2742)

* Fully deprecate NO_RELOAD

Signed-off-by: Xiao An <hac@zju.edu.cn>

* Fully deprecate TIMEOUT

Signed-off-by: Xiao An <hac@zju.edu.cn>

* Update CI tests to adapt to the deprecation of TIMEOUT

Signed-off-by: Xiao An <hac@zju.edu.cn>

* Add documents for directive transfer in plugin auto

Signed-off-by: Xiao An <hac@zju.edu.cn>
This commit is contained in:
Xiao An 2019-04-01 14:28:01 +08:00 committed by Miek Gieben
parent 99c3d065bc
commit cb96ab9f4f
9 changed files with 75 additions and 105 deletions

View file

@ -4,7 +4,6 @@ import (
"os"
"path/filepath"
"regexp"
"strconv"
"time"
"github.com/coredns/coredns/core/dnsserver"
@ -50,7 +49,7 @@ func setup(c *caddy.Controller) error {
}
go func() {
ticker := time.NewTicker(a.loader.duration)
ticker := time.NewTicker(a.loader.ReloadInterval)
for {
select {
case <-walkChan:
@ -83,7 +82,6 @@ func autoParse(c *caddy.Controller) (Auto, error) {
template: "${1}",
re: regexp.MustCompile(`db\.(.*)`),
ReloadInterval: nilInterval,
duration: nilInterval,
},
Zones: &Zones{},
}
@ -105,7 +103,7 @@ func autoParse(c *caddy.Controller) (Auto, error) {
for c.NextBlock() {
switch c.Val() {
case "directory": // directory DIR [REGEXP [TEMPLATE] [DURATION]]
case "directory": // directory DIR [REGEXP TEMPLATE]
if !c.NextArg() {
return a, c.ArgErr()
}
@ -138,17 +136,8 @@ func autoParse(c *caddy.Controller) (Auto, error) {
a.loader.template = rewriteToExpand(c.Val())
}
// duration
if c.NextArg() {
i, err := strconv.Atoi(c.Val())
if err != nil {
return a, err
}
if i < 1 {
i = 1
}
log.Warning("TIMEOUT of directory is deprecated. Use RELOAD instead. See https://coredns.io/plugins/auto/#syntax")
a.loader.duration = time.Duration(i) * time.Second
return Auto{}, c.ArgErr()
}
case "reload":
@ -158,15 +147,11 @@ func autoParse(c *caddy.Controller) (Auto, error) {
}
a.loader.ReloadInterval = d
case "no_reload":
log.Warning("NO_RELOAD of directory is deprecated. Use RELOAD (set to 0) instead. See https://coredns.io/plugins/auto/#syntax")
a.loader.ReloadInterval = 0
case "upstream":
c.RemainingArgs() // eat remaining args
a.loader.upstream = upstream.New()
default:
case "transfer":
t, _, e := parse.Transfer(c, false)
if e != nil {
return a, e
@ -174,17 +159,15 @@ func autoParse(c *caddy.Controller) (Auto, error) {
if t != nil {
a.loader.transferTo = append(a.loader.transferTo, t...)
}
default:
return Auto{}, c.Errf("unknown property '%s'", c.Val())
}
}
}
if a.loader.ReloadInterval == nilInterval {
if a.loader.duration == nilInterval {
a.loader.duration = 60 * time.Second
}
a.loader.ReloadInterval = a.loader.duration
} else if a.loader.duration == nilInterval {
a.loader.duration = a.loader.ReloadInterval
a.loader.ReloadInterval = 60 * time.Second
}
return a, nil