[DPE-10841] feat(database): client-relation manager and its mapping caches (1/7) - #216
Draft
marceloneppel wants to merge 1 commit into
Draft
[DPE-10841] feat(database): client-relation manager and its mapping caches (1/7)#216marceloneppel wants to merge 1 commit into
marceloneppel wants to merge 1 commit into
Conversation
marceloneppel
changed the base branch from
tls-files-pushed
to
refactor/inject-resource-provider
August 17, 2026 20:45
…es (1/6) The postgresql_provider migration needs a lib-side home for the client relation before either charm can hand it over. This first slice carries the parts the config flow already depends on: the username and prefix-database caches, the user->databases map, the peer user hash, and the installed-plugin list. The generated PostgreSQL role name stays substrate-derived. VM clusters hold roles named relation-<id> and K8s ones relation_id_<id>; converging the two would mean renaming roles on every deployed cluster for no functional gain, and the SQL layer already matches both forms. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
marceloneppel
force-pushed
the
refactor/inject-resource-provider
branch
from
August 18, 2026 18:23
d87aa73 to
ca66992
Compare
marceloneppel
force-pushed
the
feat/02-db-mappings
branch
from
August 18, 2026 18:23
331afd4 to
596348c
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
postgresql_provider.pystill lives in both charms (VM 645 lines, K8s 606, near-identical), and the config flow it feeds already moved into this library. Until the provider follows,update_confighas to be handed arelations_user_databases_mapand auser_hashthe charm computes from provider state, and it calls back into the charm to refresh client endpoints. This is the first of six PRs that move the whole client relation here; it carries the state the config flow already reads.Solution
Adds
managers/database.pywith the parts of the provider that are pure state:custom-usernames,prefix-databases) so deployed clusters keep their existing content;collect_user_relations()anduser_hash, which the config manager consumes in PR 4 in place of the two injected values;are_units_in_sync(), the peer-hash comparison the request handler defers on;get_plugins(), ported from both charms unchanged.The generated PostgreSQL role name is derived from the substrate rather than converged: VM clusters hold roles named
relation-<id>and K8s onesrelation_id_<id>, so a single name would require renaming roles on every deployed K8s cluster.utils/postgresql.pyalready matches both forms in its relation-user SQL.Nothing constructs this manager yet — PR 4 wires it in. Unit tests are in PRs 5 and 6, following the split used for the
update_configmigration.Stacked on #189. Next: 2/7.
Checklist