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
@@ -21,7 +21,6 @@ func TestRouteTableHappyPath(t *testing.T) {
|
||||
want string // substring the response must contain
|
||||
}{
|
||||
{name: "healthz", method: http.MethodGet, path: "/api/healthz", hook: "Health", want: `"status":"ok"`},
|
||||
{name: "dashboard", method: http.MethodGet, path: "/api/dashboard?range=1h", hook: "Dashboard", want: `"range":"1h"`},
|
||||
{name: "status", method: http.MethodGet, path: "/api/status", hook: "Status", want: `"version":"test"`},
|
||||
{name: "blocklists", method: http.MethodGet, path: "/api/blocklists", hook: "BlocklistState", want: `"lists"`},
|
||||
{name: "blocklist refresh all", method: http.MethodPost, path: "/api/blocklists/refresh", hook: "RefreshBlocklists", want: `"started":true`},
|
||||
@@ -41,10 +40,7 @@ func TestRouteTableHappyPath(t *testing.T) {
|
||||
{name: "clients put", method: http.MethodPut, path: "/api/clients", body: `{"groups":[],"default_policy":"allow"}`, hook: "PutACL", want: `"version":42`},
|
||||
{name: "upstreams get", method: http.MethodGet, path: "/api/upstreams", hook: "GetUpstream", want: `"policy":"parallel"`},
|
||||
{name: "upstreams put", method: http.MethodPut, path: "/api/upstreams", body: `{"policy":"parallel","servers":[{"addr":"127.0.0.1:53","proto":"udp"}]}`, hook: "PutUpstream", want: `"version":43`},
|
||||
{name: "logs search", method: http.MethodGet, path: "/api/logs?limit=5", hook: "SearchLog", want: `"entries"`},
|
||||
{name: "logs clear", method: http.MethodPost, path: "/api/logs/clear", hook: "ClearLog", want: `"ok":true`},
|
||||
{name: "cache stats", method: http.MethodGet, path: "/api/cache", hook: "CacheStats", want: `"entries":0`},
|
||||
{name: "cache top", method: http.MethodGet, path: "/api/cache/top?limit=7", hook: "CacheTop", want: `"items"`},
|
||||
{name: "cache flush", method: http.MethodPost, path: "/api/cache/flush", hook: "FlushCache", want: `"ok":true`},
|
||||
{name: "settings get", method: http.MethodGet, path: "/api/settings", hook: "", want: `"config_yaml"`},
|
||||
{name: "settings reload", method: http.MethodPost, path: "/api/settings/reload", hook: "", want: `"ok":true`},
|
||||
@@ -109,7 +105,6 @@ func TestReadRoutesDoNotMutate(t *testing.T) {
|
||||
path string
|
||||
}{
|
||||
{http.MethodGet, "/api/healthz"},
|
||||
{http.MethodGet, "/api/dashboard?range=24h"},
|
||||
{http.MethodGet, "/api/status"},
|
||||
{http.MethodGet, "/api/blocklists"},
|
||||
{http.MethodGet, "/api/domains"},
|
||||
@@ -117,9 +112,7 @@ func TestReadRoutesDoNotMutate(t *testing.T) {
|
||||
{http.MethodGet, "/api/zones"},
|
||||
{http.MethodGet, "/api/clients"},
|
||||
{http.MethodGet, "/api/upstreams"},
|
||||
{http.MethodGet, "/api/logs"},
|
||||
{http.MethodGet, "/api/cache"},
|
||||
{http.MethodGet, "/api/cache/top"},
|
||||
{http.MethodGet, "/api/settings"},
|
||||
{http.MethodGet, "/api/whoami"},
|
||||
}
|
||||
@@ -131,7 +124,6 @@ func TestReadRoutesDoNotMutate(t *testing.T) {
|
||||
}
|
||||
mutations := []string{
|
||||
"RefreshBlocklists", "ToggleBlocklist", "AddDomain", "DeleteDomain",
|
||||
"PutACL", "PutUpstream", "ClearLog", "FlushCache",
|
||||
"AddZoneRecord", "PutZoneRecord", "DeleteZoneRecord",
|
||||
"AddZoneDelegation", "DeleteZoneDelegation", "DeleteZone",
|
||||
}
|
||||
@@ -154,10 +146,10 @@ func TestReadRoutesDoNotMutate(t *testing.T) {
|
||||
func TestHandlerRecoversFromPanic(t *testing.T) {
|
||||
h := newHarness(t, nil)
|
||||
h.fake.mu.Lock()
|
||||
h.fake.panicOn["Dashboard"] = true
|
||||
h.fake.panicOn["CacheStats"] = true
|
||||
h.fake.mu.Unlock()
|
||||
|
||||
res := h.get("/api/dashboard")
|
||||
res := h.get("/api/cache")
|
||||
if res.status != http.StatusInternalServerError {
|
||||
t.Fatalf("panicking hook = %d, want 500: %s", res.status, res.body)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user