feat(async-replication): promotion flow, standby lifecycle, and actions (4/8) - #280
Draft
marceloneppel wants to merge 1 commit into
Draft
Conversation
marceloneppel
force-pushed
the
async-replication-3-events-core
branch
from
September 4, 2026 23:07
46387a5 to
cf50a0b
Compare
marceloneppel
force-pushed
the
async-replication-4-events-flows
branch
from
September 4, 2026 23:07
1dffc73 to
d1b2d71
Compare
marceloneppel
force-pushed
the
async-replication-3-events-core
branch
from
September 4, 2026 23:22
cf50a0b to
d398076
Compare
marceloneppel
force-pushed
the
async-replication-4-events-flows
branch
from
September 4, 2026 23:22
d1b2d71 to
7511e75
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
Completes the events handler ported in 3/8: the promotion flow and the standby lifecycle.
Solution
_can_promote_cluster,_handle_forceful_promotion,_handle_replication_change(K8s re-emits the relation-changed event, VM does not — divergence preserved; per-substrate "unit/pod addresses" action messages preserved);promote_to_primary(VM reports "Creating replication...", K8s "Promoting cluster..." — divergence preserved);_on_async_relation_changedflow helpers:_handle_late_joiner,_wait_for_all_units_stopped,_publish_stop_marker(VM-only: publishes the highest counter into the relation databag so the demoted cluster's primary-side pre-check can compare it),_start_standby_database(K8s gates on the pebble service, VM retriesstart_patroni);_configure_primary_cluster(VM's other-cluster-stopped pre-check preserved) and_configure_standby_cluster(VMsuppress-oversee-usersflag vs K8s Patroni-resource deletion);_stop_database/_stop_patroni_with_retries/_reinitialise_pgdata/_clear_pgdata(K8s-only, with thestandby-pgdata-clearedtracking),_handle_database_start/_handle_leader_database_start,_wait_for_standby_leader,_re_emit_async_relation_changed_event.Complexity stays under the repo's C901=10 by the helper extraction above; substrate branches are inline and commented.
Faithfulness note:
_stop_databasekeeps the VM charm's original behaviour — pgdata and the raft state are cleared on every unit during demotion, not only the leader — while K8s keeps the leader-first pattern with thestandby-pgdata-cleareddeferral for non-leaders.