Skip to content

[DPE-11198] feat(watcher): port the watcher relation handler from the charms (1/3) - #274

Draft
marceloneppel wants to merge 1 commit into
16/edgefrom
watcher-1-port-handler
Draft

[DPE-11198] feat(watcher): port the watcher relation handler from the charms (1/3)#274
marceloneppel wants to merge 1 commit into
16/edgefrom
watcher-1-port-handler

Conversation

@marceloneppel

@marceloneppel marceloneppel commented Sep 4, 2026

Copy link
Copy Markdown
Member

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_watcher relation (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.py ports the VM charm's PostgreSQLWatcherRelation one-to-one 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. 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_passwordstate.application.raft_password
  • charm._units_ipsstate.units_ips (new CharmState accessor reading the per-unit ip peer-databag key the lib's ClusterManager.expose_ip_and_port publishes — the lib equivalent of the charm's fresh-IP _units_ips)
  • charm.tls_manager.get_peer_ca_bundle() / is_tls_enabled → injected TLSManager
  • charm._patroni.remove_raft_member / cleanup_raft_cluster → charm-side bridges charm.remove_raft_member / charm.cleanup_raft_cluster
  • charm.async_replication.is_primary_cluster() → charm-side bridge charm.is_primary_cluster()
  • charm.refresh.pinned_snap_revisiongetattr(charm, "refresh", None) (charm_refresh stays charm-side)

Relation keys, secret label/keys, leader gates, defer conditions and cached_property semantics are unchanged. CharmState.units_ips is added here because the handout reads it.

… 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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant