Files
node-lookup/packaging/nfpm.yaml
T
Ben Vincent 2aa94f0de7
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
Add pdbmux: a merging PuppetDB proxy for the VM->k8s migration
During the VM->k8s Puppet migration there are two PuppetDBs - the legacy
Consul-registered one (http://puppetdbapi.service.consul:8080) and the new
k8s one (https://puppetdb.k8s.syd1.au.unkin.net) - and nodes move between
them as they migrate. node-lookup and pblastreport need a single, consistent
merged view without knowing which PuppetDB a node currently lives in.

This adds pdbmux, a small HTTP daemon that fronts both backends:

- Adds cmd/pdbmux/ (config.go, merge.go, server.go, main.go): a cobra tool
  whose default action (also `serve`) starts the proxy, plus config init/show
  and version subcommands, following the repo's config precedence pattern
  (defaults < config file < env PDBMUX_* < flags).
- Merges GET /pdb/query/v4/nodes: dedupes by certname, keeping the record with
  the newer report_timestamp.
- Merges GET /pdb/query/v4/facts at node granularity: keeps all facts from the
  backend owning each certname, chosen by the freshness strategy (per-certname
  report_timestamp map from /nodes, cached for freshness_ttl) or a static
  prefer-backend fallback.
- Fans out to both backends concurrently, serves the survivor if one fails, and
  returns 502 only when both fail; passes records through as raw JSON so unknown
  fields survive.
- Transparently proxies any other /pdb/query/v4/* path to the configurable
  primary, and exposes /healthz with per-backend reachability (200 ok /
  200 degraded / 503 down).
- Adds table-driven tests (go test -race, no network) covering merge logic,
  handler behaviour with httptest backends, query passthrough, one/both backend
  down, and config precedence/validation.
- Wires pdbmux into the build/release: Makefile BINARIES, scripts/build-rpm.sh,
  nfpm packaging (binary + completions + a systemd unit), and the release
  pipeline's cross-platform build + Gitea asset list.
- Documents pdbmux (what/why/endpoints/merge-semantics/config/deployment) in a
  new README.md and updates AGENTS.md.
2026-07-24 22:50:18 +10:00

107 lines
2.8 KiB
YAML

---
# nfpm config for building the node-lookup RPM.
# Rendered through envsubst (see scripts/build-rpm.sh) then fed to `nfpm pkg`.
name: ${PACKAGE_NAME}
version: ${PACKAGE_VERSION}
release: ${PACKAGE_RELEASE}
arch: ${PACKAGE_ARCH}
platform: ${PACKAGE_PLATFORM}
section: default
priority: extra
description: "${PACKAGE_DESCRIPTION}"
maintainer: ${PACKAGE_MAINTAINER}
homepage: ${PACKAGE_HOMEPAGE}
license: ${PACKAGE_LICENSE}
disable_globbing: false
replaces:
- node-lookup
provides:
- node-lookup
contents:
# The CLI binaries: node-lookup and its companion tools.
- src: dist/node-lookup
dst: /usr/bin/node-lookup
file_info:
mode: 0755
owner: root
group: root
- src: dist/pburl
dst: /usr/bin/pburl
file_info:
mode: 0755
owner: root
group: root
- src: dist/pblastreport
dst: /usr/bin/pblastreport
file_info:
mode: 0755
owner: root
group: root
- src: dist/pdbmux
dst: /usr/bin/pdbmux
file_info:
mode: 0755
owner: root
group: root
# systemd unit for the pdbmux proxy daemon (config: /etc/pdbmux/config.yaml).
- src: packaging/pdbmux.service
dst: /usr/lib/systemd/system/pdbmux.service
file_info:
mode: 0644
# Shell completions (generated by scripts/build-rpm.sh before packaging).
- src: dist/completions/node-lookup.bash
dst: /usr/share/bash-completion/completions/node-lookup
file_info:
mode: 0644
- src: dist/completions/_node-lookup
dst: /usr/share/zsh/site-functions/_node-lookup
file_info:
mode: 0644
- src: dist/completions/node-lookup.fish
dst: /usr/share/fish/vendor_completions.d/node-lookup.fish
file_info:
mode: 0644
- src: dist/completions/pburl.bash
dst: /usr/share/bash-completion/completions/pburl
file_info:
mode: 0644
- src: dist/completions/_pburl
dst: /usr/share/zsh/site-functions/_pburl
file_info:
mode: 0644
- src: dist/completions/pburl.fish
dst: /usr/share/fish/vendor_completions.d/pburl.fish
file_info:
mode: 0644
- src: dist/completions/pblastreport.bash
dst: /usr/share/bash-completion/completions/pblastreport
file_info:
mode: 0644
- src: dist/completions/_pblastreport
dst: /usr/share/zsh/site-functions/_pblastreport
file_info:
mode: 0644
- src: dist/completions/pblastreport.fish
dst: /usr/share/fish/vendor_completions.d/pblastreport.fish
file_info:
mode: 0644
- src: dist/completions/pdbmux.bash
dst: /usr/share/bash-completion/completions/pdbmux
file_info:
mode: 0644
- src: dist/completions/_pdbmux
dst: /usr/share/zsh/site-functions/_pdbmux
file_info:
mode: 0644
- src: dist/completions/pdbmux.fish
dst: /usr/share/fish/vendor_completions.d/pdbmux.fish
file_info:
mode: 0644