Make the resolver pure DNS: JSON access log on stdout instead of a log store
The resolver kept its own query-log store (a bbolt ring, a live ring with SSE fanout, rolling per-domain counters and dashboard time-series) for the console. In a multi-node deployment each pod held a different slice of that, so every view disagreed with itself, and the cost sat on the query path. Charts belong in Grafana and log search in the log collector, so the store is gone. internal/accesslog writes one JSON line per notable query to stdout. The default is what was blocked and what failed (blocked, redirected, SERVFAIL, dropped, refused); log_cached and sample_rate add ordinary answers for a debugging session. Lines go through a bounded buffer to a single writer goroutine and are dropped, and counted in fancydns_access_log_dropped_total, when the stream cannot keep up, so a stalled log pipe can never stall a query. The config key is access_log (the old qlog block is ignored, like any unknown key). The metrics gain what the dashboard used to compute: fancydns_group_queries_total by ACL group and outcome and fancydns_responses_total by RCODE. Removed with the store: /api/dashboard, /api/logs, /api/logs/stream, /api/logs/clear, /api/cache/top, the series rings, and the cache's per-name hit table, which took a mutex and built a string on every cache hit. Tests that read the old log now read the access-log lines; the contract test drops the removed endpoints. The web console still calls them and is changed in the next commit. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
dd1117fd91
commit
c6c5ca4ff7
31 files changed
+818
-3389
No files matched your search
@@ -48,19 +48,14 @@ type fakeHooks struct {
|
||||
|
||||
// arguments the API passed down, for the routes where the argument is
|
||||
// the interesting part of the contract.
|
||||
dashRange []string
|
||||
domainQuery []DomainQuery
|
||||
domainAdd []DomainInput
|
||||
domainDel []domainDelete
|
||||
aclPut []aclPut
|
||||
upstreamPut []config.Upstream
|
||||
logQuery []LogQuery
|
||||
refresh [][]string
|
||||
toggle []toggleCall
|
||||
cacheTop []int
|
||||
clearLog int
|
||||
flushes int
|
||||
logStats int
|
||||
|
||||
// fail maps a hook name to the error it should return, so the error
|
||||
// branches of a handler can be reached without a real component.
|
||||
@@ -68,12 +63,6 @@ type fakeHooks struct {
|
||||
// panicOn names hooks that panic instead of returning, which is how the
|
||||
// recoverer gets exercised.
|
||||
panicOn map[string]bool
|
||||
|
||||
// stream plumbing for the SSE test.
|
||||
stream chan LogEntry
|
||||
unsub chan struct{}
|
||||
unsubOnce sync.Once
|
||||
subs int
|
||||
}
|
||||
|
||||
type domainDelete struct {
|
||||
@@ -96,8 +85,6 @@ func newFakeHooks() *fakeHooks {
|
||||
return &fakeHooks{
|
||||
fail: map[string]error{},
|
||||
panicOn: map[string]bool{},
|
||||
stream: make(chan LogEntry, 16),
|
||||
unsub: make(chan struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,10 +161,6 @@ func (f *fakeHooks) reset() {
|
||||
|
||||
func (f *fakeHooks) hooks() Hooks {
|
||||
return Hooks{
|
||||
Dashboard: func(_ context.Context, rangeKey string) (any, error) {
|
||||
f.record("Dashboard", func() { f.dashRange = append(f.dashRange, rangeKey) })
|
||||
return map[string]any{"range": rangeKey}, f.err("Dashboard")
|
||||
},
|
||||
BlocklistState: func() any {
|
||||
f.record("BlocklistState", func() {})
|
||||
return map[string]any{"lists": []any{}}
|
||||
@@ -254,40 +237,10 @@ func (f *fakeHooks) hooks() Hooks {
|
||||
f.record("PutUpstream", func() { f.upstreamPut = append(f.upstreamPut, up) })
|
||||
return 43, f.err("PutUpstream")
|
||||
},
|
||||
SearchLog: func(_ context.Context, q LogQuery) (any, error) {
|
||||
f.record("SearchLog", func() { f.logQuery = append(f.logQuery, q) })
|
||||
return map[string]any{"entries": []any{}}, f.err("SearchLog")
|
||||
},
|
||||
LogStats: func() any {
|
||||
f.mu.Lock()
|
||||
f.logStats++
|
||||
f.mu.Unlock()
|
||||
return map[string]any{"qps": 1}
|
||||
},
|
||||
SubscribeLog: func() (<-chan LogEntry, func()) {
|
||||
f.mu.Lock()
|
||||
f.subs++
|
||||
f.calls = append(f.calls, "SubscribeLog")
|
||||
f.mu.Unlock()
|
||||
return f.stream, func() {
|
||||
f.mu.Lock()
|
||||
f.subs--
|
||||
f.mu.Unlock()
|
||||
f.unsubOnce.Do(func() { close(f.unsub) })
|
||||
}
|
||||
},
|
||||
ClearLog: func() error {
|
||||
f.record("ClearLog", func() { f.clearLog++ })
|
||||
return f.err("ClearLog")
|
||||
},
|
||||
CacheStats: func() any {
|
||||
f.record("CacheStats", func() {})
|
||||
return map[string]any{"entries": 0}
|
||||
},
|
||||
CacheTop: func(limit int) any {
|
||||
f.record("CacheTop", func() { f.cacheTop = append(f.cacheTop, limit) })
|
||||
return []any{}
|
||||
},
|
||||
FlushCache: func() int64 {
|
||||
f.record("FlushCache", func() { f.flushes++ })
|
||||
return 0
|
||||
@@ -304,20 +257,6 @@ func (f *fakeHooks) hooks() Hooks {
|
||||
}
|
||||
}
|
||||
|
||||
// subscribers is the number of live SSE subscribers; it must be back to zero
|
||||
// once a client has disconnected.
|
||||
func (f *fakeHooks) subscribers() int {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
return f.subs
|
||||
}
|
||||
|
||||
func (f *fakeHooks) statsCalls() int {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
return f.logStats
|
||||
}
|
||||
|
||||
// harness is a wired Server behind an httptest listener, with a config file on
|
||||
// disk so the settings and reload routes have something real to work on.
|
||||
type harness struct {
|
||||
|
||||
Reference in new issue
Block a user