Skip to content

Commit f6efc82

Browse files
Add extra debug to catch Raft status on CI tests
1 parent f9162b1 commit f6efc82

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/charm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ def primary_endpoint(self) -> str | None:
444444
"Possibly incoplete peer data: Will not map primary IP to unit IP"
445445
)
446446
return primary_endpoint
447+
self._patroni.log_raft_status()
447448
logger.debug("primary endpoint early exit: Primary IP not in cached peer list.")
448449
primary_endpoint = None
449450
except RetryError:

src/cluster.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,7 @@ def has_raft_quorum(self) -> bool:
827827
raft_host = "127.0.0.1:2222"
828828
try:
829829
raft_status = syncobj_util.executeCommand(raft_host, ["status"])
830+
logger.debug("Local raft status: %s", raft_status)
830831
except UtilityException:
831832
logger.warning("Has raft quorum: Cannot connect to raft cluster")
832833
return False
@@ -896,6 +897,16 @@ def get_running_cluster_members(self) -> list[str]:
896897
except Exception:
897898
return []
898899

900+
def log_raft_status(self) -> None:
901+
"""Best-effort dump of local raft status for debugging."""
902+
raft_host = "127.0.0.1:2222"
903+
try:
904+
syncobj_util = TcpUtility(password=self.raft_password, timeout=3)
905+
raft_status = syncobj_util.executeCommand(raft_host, ["status"])
906+
logger.debug("Local raft status: %s", raft_status)
907+
except UtilityException:
908+
logger.debug("Local raft status unavailable")
909+
899910
def remove_raft_member(self, member_ip: str) -> None:
900911
"""Remove a member from the raft cluster.
901912
@@ -917,6 +928,7 @@ def remove_raft_member(self, member_ip: str) -> None:
917928
raft_host = "127.0.0.1:2222"
918929
try:
919930
raft_status = syncobj_util.executeCommand(raft_host, ["status"])
931+
logger.debug("Local raft status: %s", raft_status)
920932
except UtilityException:
921933
logger.warning("Remove raft member: Cannot connect to raft cluster")
922934
raise RemoveRaftMemberFailedError() from None

0 commit comments

Comments
 (0)