Skip to content

Commit

Permalink
try catching reload errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasgameiroborges committed Nov 22, 2024
1 parent 6aa0ae4 commit e27901a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,10 @@ def _handle_postgresql_restart_need(self, enable_tls: bool) -> None:
restart_postgresql = self.is_tls_enabled != self.postgresql.is_tls_enabled()
else:
restart_postgresql = False
self._patroni.reload_patroni_configuration()
try:
self._patroni.reload_patroni_configuration()
except Exception as e:
logger.error(f"Reload patroni call failed! error: {e!s}")
# Wait for some more time than the Patroni's loop_wait default value (10 seconds),
# which tells how much time Patroni will wait before checking the configuration
# file again to reload it.
Expand Down
2 changes: 1 addition & 1 deletion src/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ def remove_raft_member(self, member_ip: str) -> None:
if "SUCCESS" not in result:
raise RemoveRaftMemberFailedError()

@retry(stop=stop_after_attempt(10), wait=wait_exponential(multiplier=1, min=2, max=10))
@retry(stop=stop_after_attempt(20), wait=wait_exponential(multiplier=1, min=2, max=10))
def reload_patroni_configuration(self):
"""Reload Patroni configuration after it was changed."""
requests.post(
Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_subordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ async def test_deploy(ops_test: OpsTest, charm: str, github_secrets):
config={"token": github_secrets["UBUNTU_PRO_TOKEN"]},
channel="latest/edge",
num_units=0,
base=CHARM_BASE,
),
ops_test.model.deploy(
LS_CLIENT,
Expand Down

0 comments on commit e27901a

Please sign in to comment.