[DPE-10881] feat(database): publish client endpoints from the manager (3/7) - #226
Open
marceloneppel wants to merge 2 commits into
Open
[DPE-10881] feat(database): publish client endpoints from the manager (3/7)#226marceloneppel wants to merge 2 commits into
marceloneppel wants to merge 2 commits into
Conversation
marceloneppel
force-pushed
the
feat/02-db-lifecycle
branch
from
August 18, 2026 18:23
4209cfb to
5a86ce7
Compare
marceloneppel
force-pushed
the
feat/02-db-endpoints
branch
from
August 18, 2026 18:23
6f88191 to
25e7a83
Compare
This was referenced Aug 20, 2026
marceloneppel
force-pushed
the
feat/02-db-lifecycle
branch
from
August 20, 2026 12:33
5a86ce7 to
332e3f8
Compare
marceloneppel
force-pushed
the
feat/02-db-endpoints
branch
from
August 20, 2026 12:33
25e7a83 to
06107b4
Compare
marceloneppel
force-pushed
the
feat/02-db-lifecycle
branch
from
August 20, 2026 15:02
332e3f8 to
610f335
Compare
marceloneppel
force-pushed
the
feat/02-db-endpoints
branch
from
August 20, 2026 15:02
06107b4 to
8f45680
Compare
marceloneppel
force-pushed
the
feat/02-db-lifecycle
branch
from
August 20, 2026 17:10
610f335 to
8547376
Compare
marceloneppel
force-pushed
the
feat/02-db-endpoints
branch
from
August 20, 2026 17:10
8f45680 to
e0bba4f
Compare
Completes the client-relation manager with the read/write and read-only endpoint publishing the config flow refreshes today through a charm bridge. VM derives the addresses from the online Patroni members, filtering out-of-sync ones; K8s reads the primary and replicas Services, so CharmState grows the replicas endpoint to match the primary one it already exposed. The read-only connection URI is now built from the read-only hosts rather than the read-only endpoints. K8s interpolated a value that already carried the port and published postgresql://user:pw@host:5432:5432/db, which no client can dial; VM's port-less form is the one both substrates now use. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Coercing a missing leader peer address to an empty string changed the published endpoint from the charm's literal "None:5432" to ":5432". Both are undialable in that stale-member edge case, but the port kept the charm's exact output so a cutover diff stays empty. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
marceloneppel
force-pushed
the
feat/02-db-lifecycle
branch
from
August 20, 2026 19:45
8547376 to
2b4cdf4
Compare
marceloneppel
force-pushed
the
feat/02-db-endpoints
branch
from
August 20, 2026 19:45
e0bba4f to
64e4163
Compare
marceloneppel
marked this pull request as ready for review
August 20, 2026 20:53
marceloneppel
requested review from
carlcsaposs-canonical,
dragomirp,
juju-charm-bot and
taurus-forever
and removed request for
a team
August 20, 2026 20:53
akram09
approved these changes
Aug 21, 2026
Comment on lines
+440
to
+447
| def _unit_ip(self, unit: Unit) -> str | None: | ||
| """The client-facing address a peer unit published for this relation.""" | ||
| if not self.state.peer_relation: | ||
| return None | ||
| try: | ||
| return self.state.peer_relation.data[unit].get(f"{self.relation_name}-address") | ||
| except KeyError: | ||
| return None |
Contributor
There was a problem hiding this comment.
This can easily go in the state
dragomirp
approved these changes
Aug 21, 2026
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
Third slice of the
postgresql_provider.pymigration. The client relation's read/write and read-only endpoints are still published by the charm, which is whyConfigManagercurrently calls back through arefresh_endpointsbridge.Solution
Completes
managers/database.pywithupdate_endpoints(), plusCharmState.replicas_endpointalongside the primary endpoint it already exposed.The two substrates compute the addresses differently and both forms are kept:
nosync, takes the leader'sdatabase-addressas the read/write endpoint and the replicas' as the read-only ones, falling back to the primary when there are no replicas. A stale leader unit missing from the peer data publishes its address verbatim (None:5432), exactly as the charm did, so a cutover diff stays empty in that corner. Handling on https://warthogs.atlassian.net/browse/DPE-10889.<app>-primaryand<app>-replicasServices.One behaviour change. The read-only connection URI is now built from the read-only hosts rather than the read-only endpoints. On K8s,
ro_endpointsalready carried:5432, and interpolating it into the URI template published a second one. Reproduced onpostgresql-k8s16/edge rev 943 againstdata-integrator:No client can dial that host. VM built the same URI from the port-less
ro_hostsand was correct; both substrates now use that form.Follow-up lib PRs:
Wiring up at:
Checklist