Repository navigation
Reload an owed pg_hba.conf and refuse pg_hba keyword names at validate (#144) - #147
Merged
Merged
Conversation
A failed pg_hba.conf check or reload made the rescue remove the Cloudfall block, after which the file no longer changed, so later converges never reloaded and PostgreSQL kept the old hostssl lines live until a restart. The rescue now leaves a per-service marker under /var/lib/cloudfall/postgresql; the next converge checks and reloads when the file changed or the marker exists, and removes the marker once pg_reload_conf() returns t. A run with neither stays unchanged. cloudfall config validate now refuses an owned database or owner named all, sameuser, samerole, samegroup or replication when the service declares remoteAccess (service_remote_access_name_reserved), instead of leaving the refusal to the role's converge-time guard, which stays. Fixes #144 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Parts 1 and 3 of #144.
A failed pg_hba.conf reload is no longer forgotten. When the check or
pg_reload_conf()failed, the rescue removed the Cloudfall block and stopped; the next converge saw an unchanged file and never reloaded, so PostgreSQL kept the oldhostssllines live until a restart. The rescue now writes a marker,{{ cloudfall_postgresql_state_directory }}/<service id>.pg_hba-reload-pending(new role default/var/lib/cloudfall/postgresql, root 0700, file 0600), before it touches the file. The check and reload run when the block changed or the marker exists, and the marker is removed once the reload returnst. A run with neither a change nor a marker stays unchanged. The marker is per service id, so two PostgreSQL services on one host never share it. Check mode stays as before: the stat runs, the check, reload and marker removal are skipped.Keyword names refused at validate.
cloudfall config validatenow refuses an owned database (or its owner) namedall,sameuser,samerole,samegrouporreplicationwhen the service declaresremoteAccess, asCONFIG_INVALIDwith codeservice_remote_access_name_reservedand the field path of the database'snameorowner. The role keeps its own guard as the second layer. WithoutremoteAccessthe names still validate. Spec 006's prose and S-006-11 list the new code.Part 2 of the issue (removing a whole Service leaves the block and listener) moved to #146.
Test plan
engine/tests/test_postgresql_remote_access.py: the stand-inpsqlcan fail the reload; new tests run the real block on localhost: a failed reload on removal writes the marker, a later converge with an unchanged file reloads and clears it, a third converge reloads nothing and reportschanged=0; a pg_hba.conf PostgreSQL cannot read also leaves the markersdk/tests/test_owned_postgresql.py: each keyword as a database name and as an owner is refused withservice_remote_access_name_reservedand the right field; the same names withoutremoteAccessvalidateuv run ruff check .,uv run mypy,uv run cloudfall config validate --project config/examplespass;uv run pyteston the three touched test files (SDK and engine) passes, 80 testsuv run ansible-lint engine/ansiblepasses when run fromengine/ansible(where itsansible.cfgsetsroles_path); from the repo root of this agent worktree it reports role-not-found syntax errors in five untouched playbooks, an environment issue of the worktree path, so CI's run is the authorityFixes #144
🤖 Generated with Claude Code