[DPE-10841] feat(database): relation user lifecycle and blocking statuses (2/7) - #217
Draft
marceloneppel wants to merge 1 commit into
Draft
[DPE-10841] feat(database): relation user lifecycle and blocking statuses (2/7)#217marceloneppel wants to merge 1 commit into
marceloneppel wants to merge 1 commit into
Conversation
marceloneppel
force-pushed
the
feat/02-db-lifecycle
branch
from
August 18, 2026 13:31
848539e to
0958b21
Compare
…uses (2/6) Second slice of the client-relation manager: creating and dropping the relation user and database, overseeing users whose relation went away, and the blocked-status bookkeeping that clears once the offending request is gone. Two behaviours stay substrate-specific because widening either would change what a live cluster does. VM blocks on the whole PostgreSQL error hierarchy where K8s blocks on three specific errors, and VM accepts "createdb" as an extra user role although PostgreSQL does not report it as a privilege or role. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
marceloneppel
force-pushed
the
feat/02-db-mappings
branch
from
August 18, 2026 18:23
331afd4 to
596348c
Compare
marceloneppel
force-pushed
the
feat/02-db-lifecycle
branch
from
August 18, 2026 18:23
4209cfb to
5a86ce7
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
Second slice of the
postgresql_provider.pymigration. PR 1 landed the manager's state; this one carries the work it guards: creating and dropping the PostgreSQL user and database behind a client relation, and the blocked-status bookkeeping that decides when a failed request is cleared.Solution
Adds to
managers/database.py:get_credentials()/collect_databases()— resolve the requested user and database (including the prefixeddb*form), blocking on a forbidden username, an unreadable requested-entity secret, or a prefix shorter than three characters;create_relation_user_and_database()anddelete_relation_user();oversee_users()— drops relation users whose relation is gone, honouring thesuppress-oversee-usersflag;check_for_invalid_extra_user_roles(),check_for_invalid_database_name(),unblock_custom_user_errors(),update_unit_status().Two divergences are preserved rather than merged, because widening either changes what a live cluster does:
PostgreSQLBaseErrorhierarchy; K8s catches onlyPostgreSQLCreateDatabaseError,PostgreSQLCreateUserErrorandPostgreSQLGetPostgreSQLVersionError. Widening K8s would newly block requests that today raise through.createdbas an extra user role. VM accepts it even though PostgreSQL reports it as neither a privilege nor a role; K8s rejects it.One deviation worth calling out: all status writes go through the charm's refresh-aware
set_unit_status. The two charms were inconsistent here — VM assignedunit.statusdirectly in_get_credentialswhile K8s used the helper, and they swapped roles at the end of_unblock_custom_user_errors. Preserving that would mean a substrate branch per call site for a difference neither charm looks deliberate about; the helper is the safer of the two, since it does not overwrite a higher-priority refresh status.Unit tests are in PRs 5 and 6.
Stacked on 1/7. Next: 3/7.
Checklist