Answer AST name queries for pdbmux_source on /facts #30

Merged
benvin merged 2 commits from benvin/pdbmux-source-fact-ast into main 2026-10-10 01:06:53 +11:00
Member

/facts AST queries naming pdbmux_source (node-lookup -F, puppetboard inventory) are fanned out as-is, and no backend holds that fact, so they return nothing while the /facts/pdbmux_source path works.

  • select the source fact when a =/~/in-array name comparison matches it
  • evaluate and/or/not over =/~/in on certname/environment/name/value locally
  • add the matching synthetic records, from the drilldown merge, to the fanned-out response
  • fetch the synthetic set with only the query's top-level certname conjuncts
  • report only backends alive for both fetches in X-Backends
  • share the synthetic-set fetch with serveSourceFact
`/facts` AST queries naming `pdbmux_source` (node-lookup `-F`, puppetboard inventory) are fanned out as-is, and no backend holds that fact, so they return nothing while the `/facts/pdbmux_source` path works. - select the source fact when a `=`/`~`/`in`-array name comparison matches it - evaluate and/or/not over `=`/`~`/`in` on certname/environment/name/value locally - add the matching synthetic records, from the drilldown merge, to the fanned-out response - fetch the synthetic set with only the query's top-level certname conjuncts - report only backends alive for both fetches in `X-Backends` - share the synthetic-set fetch with `serveSourceFact`
unkin-agent added 1 commit 2026-10-09 23:42:06 +11:00
Answer AST name queries for the source fact on /facts
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
0aff1746e2
Author
Member
  • server.go:411 — s.sourceFacts(ctx, ..., nil) fans out an unfiltered whole-estate /facts on every request (facts are never cached), even for a single-host query like ["and",["=","certname","h1"],["=","name","pdbmux_source"]]; the drilldown it replaces narrows by params → pass the query's top-level and certname/environment conjuncts as the second fetch's query.
  • nit: server.go:425 — X-Backends counts only the first fetch's alive; a backend lost during the line-411 fetch silently drops its nodes' synthetic records while the header still says 2/2 → count the smaller of the two alive sets.
  • nit: source.go:213 — ponytail: comment is wrong: ["not",["=","name","pdbmux_source"]] is selected (namesFact descends into not); the real gap is ["not",["=","name","osfamily"]] returning no synthetic records → reword.
- server.go:411 — `s.sourceFacts(ctx, ..., nil)` fans out an unfiltered whole-estate `/facts` on every request (facts are never cached), even for a single-host query like `["and",["=","certname","h1"],["=","name","pdbmux_source"]]`; the drilldown it replaces narrows by `params` → pass the query's top-level `and` certname/environment conjuncts as the second fetch's query. - nit: server.go:425 — `X-Backends` counts only the first fetch's `alive`; a backend lost during the line-411 fetch silently drops its nodes' synthetic records while the header still says 2/2 → count the smaller of the two alive sets. - nit: source.go:213 — `ponytail:` comment is wrong: `["not",["=","name","pdbmux_source"]]` is selected (namesFact descends into `not`); the real gap is `["not",["=","name","osfamily"]]` returning no synthetic records → reword.
unkin-agent added 1 commit 2026-10-09 23:48:02 +11:00
Narrow the source-fact /facts fetch to the query's certnames
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
97ddc378ff
Author
Member

nit: source.go:259 — namesFact descends into not, so ["not",["=","name","pdbmux_source"]] is taken as selecting the fact: it adds an unscoped whole-estate /facts fetch (and can drop X-Backends) for a query that never returns a synthetic record → stop descending into not (only and/or).

nit: source.go:259 — `namesFact` descends into `not`, so `["not",["=","name","pdbmux_source"]]` is taken as selecting the fact: it adds an unscoped whole-estate `/facts` fetch (and can drop `X-Backends`) for a query that never returns a synthetic record → stop descending into `not` (only `and`/`or`).
benvin merged commit c75d0db69e into main 2026-10-10 01:06:53 +11:00
benvin deleted branch benvin/pdbmux-source-fact-ast 2026-10-10 01:06:53 +11:00
Sign in to join this conversation.