mirror of
https://github.com/coredns/coredns.git
synced 2026-10-27 12:45:43 -04:00
plugin/forward: add startup health checks with start_failed (#8663)
* plugin/forward: add startup health checks with start_failed Signed-off-by: houyuwushang <180804215+houyuwushang@users.noreply.github.com> * test: separate CoreDNS and third-party imports Signed-off-by: houyuwushang <180804215+houyuwushang@users.noreply.github.com> --------- Signed-off-by: houyuwushang <180804215+houyuwushang@users.noreply.github.com>
This commit is contained in:
@@ -75,6 +75,9 @@ func setup(c *caddy.Controller) error {
|
||||
func (f *Forward) OnStartup() (err error) {
|
||||
for _, p := range f.proxies {
|
||||
p.Start(f.hcInterval)
|
||||
if f.startFailed {
|
||||
p.StartFailed()
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -158,6 +161,9 @@ func parseStanza(c *caddy.Controller) (*Forward, error) {
|
||||
if f.maxAge > 0 && f.maxAge < f.expire {
|
||||
return f, fmt.Errorf("max_age (%s) must not be less than expire (%s)", f.maxAge, f.expire)
|
||||
}
|
||||
if f.startFailed && f.maxfails == 0 {
|
||||
return f, fmt.Errorf("start_failed requires health checking; max_fails must be greater than zero")
|
||||
}
|
||||
|
||||
// Reject HTTPS upstreams that include a path, the doh implementation default to /dns-query path.
|
||||
for _, addr := range to {
|
||||
@@ -290,6 +296,11 @@ func parseBlock(c *caddy.Controller, f *Forward) error {
|
||||
return err
|
||||
}
|
||||
f.maxfails = uint32(n)
|
||||
case "start_failed":
|
||||
if c.NextArg() {
|
||||
return c.ArgErr()
|
||||
}
|
||||
f.startFailed = true
|
||||
case "max_connect_attempts":
|
||||
if !c.NextArg() {
|
||||
return c.ArgErr()
|
||||
|
||||
Reference in New Issue
Block a user