feat(config): move patroni template into the lib as one substrate-conditional template#183
Draft
marceloneppel wants to merge 1 commit into
Draft
Conversation
…ditional template The two charms each carried their own templates/patroni.yml.j2 and the config manager loaded it with a CWD-relative open(), so the lib could not own the render. Merge both copies into a single template the lib ships and loads as package data, so the charms delete their copies in the adoption PR and the template travels with the code that renders it rather than with each charm's working directory. The VM and K8s templates diverge in section ordering, whole blocks (raft, bypass_api_service, pod_ip), path variables, and pg_hba rules, so the merged template branches at the top level on a substrate context var with each substrate's body kept verbatim. That guarantees byte-for-byte identical output per substrate and avoids interleaving conditionals that could silently shift a byte. render_patroni_yml_file now loads the template via importlib.resources and passes the substrate the template branches on. Golden tests render the merged template against byte copies of each charm's original template across the full matrix of conditional dimensions (tls, connectivity, ldap, restore/pitr, slots, peers, watcher, extra replication endpoints, tags) and assert equality, so any divergent byte fails the suite. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
cba92af to
fdf2a44
Compare
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.
Issue
Each charm ships its own
templates/patroni.yml.j2, loaded from the current working directory. The library must own the template and load it as package data sorender_patroni_yml_fileworks regardless of CWD.Solution
patroni.yml.j2into one lib-ownedsingle_kernel_postgresql/templates/patroni.yml.j2that branches on asubstratecontext var; each branch is a byte-for-byte copy of the corresponding charm template.importlib.resourcesinstead of a CWD-relativeopen(); add"substrate"to the render context.Third PR in the update_config stack (base
skl-01-update-config-2-params).Checklist