mirror of
https://github.com/coredns/coredns.git
synced 2025-12-31 14:01:22 -05:00
plugin/secondary: fix a bunch of things and tests (#1406)
Fix the error handling. Log when we have an error during any of the transfer state. And if there isn't an error transfer the zones. Also fix the tests in test/ so we, at least, check the initial transfer. Update the docs to show more about how errors are handled. Ref #1400
This commit is contained in:
@@ -118,19 +118,6 @@ Restart:
|
||||
retry := time.Second * time.Duration(z.Apex.SOA.Retry)
|
||||
expire := time.Second * time.Duration(z.Apex.SOA.Expire)
|
||||
|
||||
if refresh < time.Hour {
|
||||
refresh = time.Hour
|
||||
}
|
||||
if retry < time.Hour {
|
||||
retry = time.Hour
|
||||
}
|
||||
if refresh > 24*time.Hour {
|
||||
refresh = 24 * time.Hour
|
||||
}
|
||||
if retry > 12*time.Hour {
|
||||
retry = 12 * time.Hour
|
||||
}
|
||||
|
||||
refreshTicker := time.NewTicker(refresh)
|
||||
retryTicker := time.NewTicker(retry)
|
||||
expireTicker := time.NewTicker(expire)
|
||||
@@ -151,7 +138,12 @@ Restart:
|
||||
time.Sleep(jitter(2000)) // 2s randomize
|
||||
|
||||
ok, err := z.shouldTransfer()
|
||||
if err != nil && ok {
|
||||
if err != nil {
|
||||
log.Printf("[WARNING] Failed retry check %s", err)
|
||||
continue
|
||||
}
|
||||
|
||||
if ok {
|
||||
if err := z.TransferIn(); err != nil {
|
||||
// transfer failed, leave retryActive true
|
||||
break
|
||||
@@ -169,8 +161,13 @@ Restart:
|
||||
time.Sleep(jitter(5000)) // 5s randomize
|
||||
|
||||
ok, err := z.shouldTransfer()
|
||||
retryActive = err != nil
|
||||
if err != nil && ok {
|
||||
if err != nil {
|
||||
log.Printf("[WARNING] Failed refresh check %s", err)
|
||||
retryActive = true
|
||||
continue
|
||||
}
|
||||
|
||||
if ok {
|
||||
if err := z.TransferIn(); err != nil {
|
||||
// transfer failed
|
||||
retryActive = true
|
||||
|
||||
@@ -35,6 +35,10 @@ secondary [zones...] {
|
||||
normal authoritative serving you don't need *or* want to use this. **ADDRESS** can be an IP
|
||||
address, and IP:port or a string pointing to a file that is structured as /etc/resolv.conf.
|
||||
|
||||
When a zone is due to be refreshed (Refresh timer fires) a random jitter of 5 seconds is
|
||||
applied, before fetching. In the case of retry this will be 2 seconds. If there are any errors
|
||||
during the transfer the transfer fails; this will be logged.
|
||||
|
||||
## Examples
|
||||
|
||||
Transfer `example.org` from 10.0.1.1, and if that fails try 10.1.2.1.
|
||||
|
||||
Reference in New Issue
Block a user