fix(config-init): make config seeding idempotent via version marker

Closes #175 (closed)

Summary

  • config/init-configs.sh now writes /target/.pgai-configs-version after each successful copy and short-circuits on subsequent runs when the marker matches the image's /VERSION.
  • Stops docker compose up from silently reseeding the postgres_ai_configs volume on every restart, which was wiping production-side edits to pgwatch{,-prometheus}/metrics.yml (e.g. the calls >= 3 filter cherry-picked from !220 (closed)).
  • Adds tests/compliance_vectors/test_init_configs.py (committed first per TDD) covering empty target, matching marker (skip + preserve user edit), mismatched marker, and missing marker on a non-empty target.

Test plan

  • python3 -m pytest tests/compliance_vectors/test_init_configs.py -v passes (4 passed) against the patched script.
  • Same suite fails (4 failed) against current main — confirms the test actually exercises the bug (TDD red, then green).
  • shellcheck config/init-configs.sh clean.
  • Manual: on a 0.14.0+1 monitoring VM, edit pgwatch-prometheus/metrics.yml, run docker compose -f docker-compose.yml -p monitoring up -d sink-prometheus, confirm the edit survives and config-init logs Configs already initialized at version <v>; skipping..
  • Manual: bump configs image to a newer version on the same volume, run compose, confirm the edit is overwritten and the marker file contents update to the new version.

Migration / breaking changes

Operators who upgrade the postgres-ai-configs image while keeping the same postgres_ai_configs volume and want to pull in the new image defaults must either:

  • delete the marker before bringing the stack up, e.g. docker exec config-init rm /target/.pgai-configs-version (or remove the file directly from the host volume mount), or
  • recreate the volume (docker compose down -v and back up first if you have local edits worth keeping).

The script will then reseed the volume and write the new version marker. This is documented in a comment block inside init-configs.sh.

Merge request reports

Loading