healthcheck: answer 503 when no root server gave a usable reply in the last round of DNS checks (closes #302)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
The health check answered ok while every DNS lookup failed, as on a network that intercepts DNS queries. A lookup whose root servers give no usable reply now fails with ErrNoRootServerAnswered. At the end of each round of DNS checks that shutdown did not cut short, the watcher records whether every lookup failed with it or with ErrIntercepted; the health check then gives status error, and /.well-known/healthcheck and /health answer 503. Until the first round finishes it stays ok. The health check now depends on the watcher, so fx starts the watcher before the HTTP server and stops the server first. NewWithRootServers lets tests start a resolver's walks at real servers that are not root servers. Model: opus-5-5
This commit was merged in pull request #304.
This commit is contained in:
@@ -15,14 +15,21 @@ import (
|
||||
"sneak.berlin/go/dnswatcher/internal/logger"
|
||||
"sneak.berlin/go/dnswatcher/internal/middleware"
|
||||
"sneak.berlin/go/dnswatcher/internal/notify"
|
||||
"sneak.berlin/go/dnswatcher/internal/portcheck"
|
||||
"sneak.berlin/go/dnswatcher/internal/resolver"
|
||||
"sneak.berlin/go/dnswatcher/internal/server"
|
||||
"sneak.berlin/go/dnswatcher/internal/state"
|
||||
"sneak.berlin/go/dnswatcher/internal/tlscheck"
|
||||
"sneak.berlin/go/dnswatcher/internal/watcher"
|
||||
)
|
||||
|
||||
// newServerApp builds an fx app holding a *server.Server wired exactly
|
||||
// as cmd/dnswatcher wires it, minus the watcher/resolver subtree that
|
||||
// would touch live DNS, plus the given option. config.New reads viper,
|
||||
// so the caller must first configure it, which is also why the caller
|
||||
// as cmd/dnswatcher wires it, plus the given option. The health check
|
||||
// follows the watcher, so the watcher is in the app too. Starting the
|
||||
// app starts the watcher's first round of checks, against live DNS,
|
||||
// before the server; the tests that start it expect the server to fail
|
||||
// to start, which stops the watcher again. config.New reads viper, so
|
||||
// the caller must first configure it, which is also why the caller
|
||||
// cannot run in parallel.
|
||||
func newServerApp(option fx.Option) *fx.App {
|
||||
return fx.New(
|
||||
@@ -33,11 +40,29 @@ func newServerApp(option fx.Option) *fx.App {
|
||||
config.New,
|
||||
state.New,
|
||||
healthcheck.New,
|
||||
resolver.New,
|
||||
portcheck.New,
|
||||
tlscheck.New,
|
||||
notify.New,
|
||||
watcher.New,
|
||||
middleware.New,
|
||||
handlers.New,
|
||||
server.New,
|
||||
),
|
||||
fx.Provide(
|
||||
func(r *resolver.Resolver) watcher.DNSResolver {
|
||||
return r
|
||||
},
|
||||
func(p *portcheck.Checker) watcher.PortChecker {
|
||||
return p
|
||||
},
|
||||
func(t *tlscheck.Checker) watcher.TLSChecker {
|
||||
return t
|
||||
},
|
||||
func(n *notify.Service) watcher.Notifier {
|
||||
return n
|
||||
},
|
||||
),
|
||||
option,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user