[DPE-11198] feat(watcher): port the watcher relation handler from the charms (1/3) - #274
Draft
marceloneppel wants to merge 1 commit into
Draft
[DPE-11198] feat(watcher): port the watcher relation handler from the charms (1/3)#274marceloneppel wants to merge 1 commit into
marceloneppel wants to merge 1 commit into
Conversation
This was referenced Sep 4, 2026
… charms (1/3) Ports the VM charm's watcher relation module into the library as a substrate-neutral WatcherEventsHandler, part 1 of 3: the stereo-mode watcher-offer relation accessors (Raft address, raft-status gate), the enable/disable handshake, the watcher PostgreSQL user lifecycle, the secret get-or-create/update paths and the relation-data handout. - Charm-side bridges stay for the residual RAFT operations (cleanup_raft_cluster / remove_raft_member), the async-replication primary check, the charm_refresh object, the postgresql client and update_config, until their own migration phases. - Charm-attribute reads move to injected collaborators: state.application.raft_password, state.application.cluster_name, state.application.is_cluster_initialised, state.units_ips and the injected tls_manager/workload. - Adds CharmState.units_ips: fresh per-unit IPs read from the peer relation's unit databags (the "ip" key ClusterManager.expose_ip_and_port publishes) instead of the possibly stale app-level member list — the lib equivalent of the charm's _units_ips the watcher handout consumed. The relation events (joined/changed/broken) and the charm wiring land in (2/3); the tests and the 16.3.14 bump in (3/3).
marceloneppel
force-pushed
the
watcher-1-port-handler
branch
from
September 4, 2026 22:00
237fa74 to
b4fc39b
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
Follows the module-migration series (database 216-222, tls 180-189, ldap 235/236, backups 238-256): ports the watcher relation module from the VM charm's 16/edge into the library. The K8s charm has no watcher module — it offers no
postgresql_watcherrelation (Patroni uses the K8s API as its DCS) — so this handler is constructed on VM only, mirroring how K8sManager is K8s-only.Solution
events/watcher.pyports the VM charm'sPostgreSQLWatcherRelationone-to-one as a substrate-neutralWatcherEventsHandler, part 1 of 3: the stereo-modewatcher-offerrelation accessors (Raft address,raft-statusgate), the enable/disable handshake, the watcher PostgreSQL user lifecycle, the secret get-or-create/update paths and the relation-data handout. The three relation event handlers and the charm wiring land in (2/3); the tests and the 16.3.14 bump in (3/3).Adapter substitutions per the established contract:
charm._patroni.raft_password→state.application.raft_passwordcharm._units_ips→state.units_ips(newCharmStateaccessor reading the per-unitippeer-databag key the lib'sClusterManager.expose_ip_and_portpublishes — the lib equivalent of the charm's fresh-IP_units_ips)charm.tls_manager.get_peer_ca_bundle()/is_tls_enabled→ injectedTLSManagercharm._patroni.remove_raft_member/cleanup_raft_cluster→ charm-side bridgescharm.remove_raft_member/charm.cleanup_raft_clustercharm.async_replication.is_primary_cluster()→ charm-side bridgecharm.is_primary_cluster()charm.refresh.pinned_snap_revision→getattr(charm, "refresh", None)(charm_refresh stays charm-side)Relation keys, secret label/keys, leader gates, defer conditions and
cached_propertysemantics are unchanged.CharmState.units_ipsis added here because the handout reads it.