Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ charm-refresh = "^3.1.0.2"
charmlibs-snap = "^1.0.1"
charmlibs-systemd = "^1.0.0.post0"
charmlibs-interfaces-tls-certificates = "^1.10.1"
postgresql-charms-single-kernel = {extras = ["postgresql", "vm"], version = "16.3.7"}
postgresql-charms-single-kernel = {extras = ["postgresql", "vm"], url = "https://github.com/canonical/postgresql-single-kernel-library/archive/3d9478488e1f739649282c86e1218dd92fc96eca.tar.gz"}

[tool.poetry.group.charm-libs.dependencies]
# data_platform_libs/v0/data_interfaces.py
Expand Down
24 changes: 19 additions & 5 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
)
from ldap import PostgreSQLLDAP
from relations.async_replication import PostgreSQLAsyncReplication
from relations.watcher import PostgreSQLWatcherRelation
from single_kernel_postgresql.events.watcher import WatcherEventsHandler
from rotate_logs import RotateLogs

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -454,7 +454,12 @@ def __init__(self, *args):
self.framework.observe(self.tls.tls_files_pushed, self._reload_tls_after_push)
self.tls_transfer = TLSTransfer(self, PEER_RELATION)
self.async_replication = PostgreSQLAsyncReplication(self)
self.watcher_offer = PostgreSQLWatcherRelation(self)
self.watcher_offer = WatcherEventsHandler(
self,
state=self.state,
workload=self.workload,
tls_manager=self.tls_manager,
)
# self.logical_replication = PostgreSQLLogicalReplication(self)
self.restart_manager = RollingOpsManager(
charm=self, relation="restart", callback=self._restart
Expand Down Expand Up @@ -2754,6 +2759,18 @@ def request_restart(self) -> None:
self.unit_peer_data.pop("postgresql_restarted", None)
self.on[str(self.restart_manager.name)].acquire_lock.emit()

def cleanup_raft_cluster(self) -> bool:
"""Remove stale RAFT members not belonging to the cluster or the watcher. Bridge for the lib watcher handler."""
return self._patroni.cleanup_raft_cluster()

def remove_raft_member(self, address: str) -> None:
"""Remove a RAFT member. Bridge for the lib watcher handler."""
self._patroni.remove_raft_member(address)

def is_primary_cluster(self) -> bool:
"""Whether this cluster is the async-replication primary. Bridge for the lib watcher handler."""
return self.async_replication.is_primary_cluster()

def restart_services(self) -> None:
"""Restart the monitoring and LDAP sync snap services if needed. Bridge for ConfigManager."""
cache = snap.SnapCache()
Expand All @@ -2779,9 +2796,6 @@ def update_config(
async_primary_cluster_endpoint=self.async_replication.get_primary_cluster_endpoint(),
async_partner_addresses=self.async_replication.get_partner_addresses(),
async_standby_endpoints=self.async_replication.get_standby_endpoints(),
watcher_raft_address=self.watcher_offer.watcher_raft_address
if self.watcher_offer.is_active
else None,
no_peers=no_peers,
refresh=refresh,
)
Expand Down
Loading
Loading