Skip to content

Commit

Permalink
Merge branch 'main' into update-snap
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomirp committed Apr 4, 2024
2 parents 3dc464e + c131d82 commit 031f229
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
16 changes: 8 additions & 8 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 @@ -15,7 +15,7 @@ repository = "https://github.com/canonical/postgresql-operator"
python = "^3.10"
ops = "^2.12.0"
cryptography = "^42.0.5"
boto3 = "^1.34.75"
boto3 = "^1.34.76"
pgconnstr = "^1.0.1"
requests = "^2.31.0"
tenacity = "^8.2.3"
Expand Down
18 changes: 17 additions & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import os
import platform
import subprocess
import sys
from pathlib import Path
from typing import Dict, List, Literal, Optional, Set, get_args

import psycopg2
Expand Down Expand Up @@ -106,6 +108,16 @@ class PostgresqlOperatorCharm(TypedCharmBase[CharmConfig]):
def __init__(self, *args):
super().__init__(*args)

# Support for disabling the operator.
disable_file = Path(f"{os.environ.get('CHARM_DIR')}/disable")
if disable_file.exists():
logger.warning(
f"\n\tDisable file `{disable_file.resolve()}` found, the charm will skip all events."
"\n\tTo resume normal operations, please remove the file."
)
self.unit.status = BlockedStatus("Disabled")
sys.exit(0)

self.peer_relation_app = DataPeer(
self,
relation_name=PEER,
Expand Down Expand Up @@ -1489,7 +1501,11 @@ def update_config(self, is_creating_backup: bool = False) -> bool:
"max_prepared_transactions": self.config.memory_max_prepared_transactions,
})

self._handle_postgresql_restart_need(enable_tls)
try:
self._handle_postgresql_restart_need(enable_tls)
except RetryError:
logger.warning("Early exit update_config: Cannot handle restrt need")
return False

# Restart the monitoring service if the password was rotated
cache = snap.SnapCache()
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async def test_backup(ops_test: OpsTest, cloud_configs: Tuple[Dict, Dict]) -> No
await action.wait()
async with ops_test.fast_forward(fast_interval="60s"):
await ops_test.model.wait_for_idle(
apps=[database_app_name, S3_INTEGRATOR_APP_NAME], status="active", timeout=1200
apps=[database_app_name, S3_INTEGRATOR_APP_NAME], status="active", timeout=1500
)

primary = await get_primary(ops_test, f"{database_app_name}/0")
Expand Down

0 comments on commit 031f229

Please sign in to comment.