Skip to content

refactor(watcher): use the watcher module from the single kernel library - #1943

Draft
marceloneppel wants to merge 1 commit into
16/edgefrom
watcher-adopt-lib
Draft

refactor(watcher): use the watcher module from the single kernel library#1943
marceloneppel wants to merge 1 commit into
16/edgefrom
watcher-adopt-lib

Conversation

@marceloneppel

Copy link
Copy Markdown
Member

Issue

Follows the watcher module migration into the single kernel library (postgresql-single-kernel-library #274, #275, #276).

Solution

The charm drops its own watcher module in favour of the library's substrate-neutral WatcherEventsHandler, ported from the VM charm's src/relations/watcher.py. The stereo-mode watcher-offer relation, the Raft secret handout, the watcher PostgreSQL user lifecycle and the per-unit address publishing are owned by the library now.

The charm keeps the substrate-tangled pieces the handler consumes as bridges, until their own migration phases (RAFT manager, async-replication manager, charm_refresh):

  • cleanup_raft_cluster / remove_raft_member delegate to the residual RAFT Patroni;
  • is_primary_cluster delegates to the async-replication module;
  • update_config no longer threads watcher_raft_address — the library's config manager sources the Raft address from the injected handler.

The unit tests for the module live in the library (tests/unit/test_watcher.py), where they run against the substrate-parameterised harness; the charm's tests/unit/test_charm.py watcher patches carry over unchanged.

The library is pinned at commit 3d9478488e1f739649282c86e1218dd92fc96eca (= 16.3.14) via archive URL, so CI exercises exactly the draft library stack.

Adopts the library's substrate-neutral WatcherEventsHandler (postgresql-single-kernel-library #274-#276, pinned at 3d9478488e1f739649282c86e1218dd92fc96eca = 16.3.14): the stereo-mode watcher-offer relation, the Raft secret handout, the watcher PostgreSQL user lifecycle and the per-unit address publishing move to the library; the charm drops src/relations/watcher.py and its unit tests.

The charm keeps the substrate-tangled pieces the handler consumes as bridges: cleanup_raft_cluster / remove_raft_member delegate to the residual RAFT Patroni, is_primary_cluster to the async-replication module, and update_config no longer threads watcher_raft_address — the library's config manager sources it from the injected handler.

The tests for the module now live in the library (test_watcher.py), where they run against both substrate harnesses.

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
@github-actions github-actions Bot added the Libraries: Out of sync The charm libs used are out-of-sync label Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Libraries: Out of sync The charm libs used are out-of-sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant