Replay a unanimous upstream rejection instead of a 502
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful

Every backend gets the same query, so one they all refuse is the client's
mistake; flattening it into "all backends failed" threw openvoxdb's own
explanation away and logged a typo as an outage.

- Carry status, content type and body on a typed upstreamError
- Replay the status and explanation when every backend refuses alike
- Redact backend addresses from replayed bodies
- Keep a refused query out of the partial counters and the cache
This commit is contained in:
2026-09-07 22:39:58 +10:00
parent 85d134a449
commit bfe28b488d
7 changed files with 676 additions and 11 deletions
+8
View File
@@ -31,6 +31,10 @@ type fakeBackend struct {
totals map[string]int
fail bool // return 500 for everything
delay time.Duration // artificial latency
// reject answers every request with this status and rejectBody, standing in
// for a PuppetDB refusing a query it cannot answer.
reject int
rejectBody string
mu sync.Mutex
gotParams map[string]url.Values
@@ -60,6 +64,10 @@ func newFakeBackend(t *testing.T, nodesBody, factsBody string) *fakeBackend {
http.Error(w, "boom", http.StatusInternalServerError)
return
}
if fb.reject != 0 {
http.Error(w, fb.rejectBody, fb.reject)
return
}
if body, ok := fb.bodies[r.URL.Path]; ok {
if n, ok := fb.totals[r.URL.Path]; ok && r.URL.Query().Get("include_total") == "true" {
w.Header().Set(recordsHeader, strconv.Itoa(n))