Skip to content

Commit ac3a314

Browse files
[DPE-3217] Update Snap to 14.10 + housekeeping (cleanup) (#316)
* Update snap to 14.10 and disable landscape tests * Skip instead of make unstable * Outdated locales * Update Patroni config in one go * Cleanup after moving Peer Data usage to data_platform_libs/data_interfaces --------- Co-authored-by: Judit Novak <[email protected]>
1 parent 368dba7 commit ac3a314

File tree

5 files changed

+9
-154
lines changed

5 files changed

+9
-154
lines changed

lib/charms/data_platform_libs/v0/data_secrets.py

Lines changed: 0 additions & 143 deletions
This file was deleted.

src/charm.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
from charms.data_platform_libs.v0.data_interfaces import DataPeer, DataPeerUnit
1414
from charms.data_platform_libs.v0.data_models import TypedCharmBase
15-
from charms.data_platform_libs.v0.data_secrets import SecretCache
1615
from charms.grafana_agent.v0.cos_agent import COSAgentProvider
1716
from charms.operator_libs_linux.v2 import snap
1817
from charms.postgresql_k8s.v0.postgresql import (
@@ -102,7 +101,6 @@ class PostgresqlOperatorCharm(TypedCharmBase[CharmConfig]):
102101
def __init__(self, *args):
103102
super().__init__(*args)
104103

105-
self.secrets = SecretCache(self)
106104
self.peer_relation_app = DataPeer(
107105
self,
108106
relation_name=PEER,
@@ -1391,11 +1389,11 @@ def update_config(self, is_creating_backup: bool = False) -> bool:
13911389

13921390
self._validate_config_options()
13931391

1394-
self._patroni.update_parameter_controller_by_patroni(
1395-
"max_connections", max(4 * os.cpu_count(), 100)
1396-
)
1397-
self._patroni.update_parameter_controller_by_patroni(
1398-
"max_prepared_transactions", self.config.memory_max_prepared_transactions
1392+
self._patroni.bulk_update_parameters_controller_by_patroni(
1393+
{
1394+
"max_connections": max(4 * os.cpu_count(), 100),
1395+
"max_prepared_transactions": self.config.memory_max_prepared_transactions,
1396+
}
13991397
)
14001398

14011399
restart_postgresql = self.is_tls_enabled != self.postgresql.is_tls_enabled()

src/cluster.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,15 +623,15 @@ def reinitialize_postgresql(self) -> None:
623623
requests.post(f"{self._patroni_url}/reinitialize", verify=self.verify)
624624

625625
@retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=2, max=10))
626-
def update_parameter_controller_by_patroni(self, parameter: str, value: Any) -> None:
626+
def bulk_update_parameters_controller_by_patroni(self, parameters: Dict[str, Any]) -> None:
627627
"""Update the value of a parameter controller by Patroni.
628628
629629
For more information, check https://patroni.readthedocs.io/en/latest/patroni_configuration.html#postgresql-parameters-controlled-by-patroni.
630630
"""
631631
requests.patch(
632632
f"{self._patroni_url}/config",
633633
verify=self.verify,
634-
json={"postgresql": {"parameters": {parameter: value}}},
634+
json={"postgresql": {"parameters": parameters}},
635635
)
636636

637637
def update_synchronous_node_count(self, units: int = None) -> None:

src/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# Snap constants.
3333
PGBACKREST_EXECUTABLE = "charmed-postgresql.pgbackrest"
3434
POSTGRESQL_SNAP_NAME = "charmed-postgresql"
35-
SNAP_PACKAGES = [(POSTGRESQL_SNAP_NAME, {"revision": "89"})]
35+
SNAP_PACKAGES = [(POSTGRESQL_SNAP_NAME, {"revision": "95"})]
3636

3737
SNAP_COMMON_PATH = "/var/snap/charmed-postgresql/common"
3838
SNAP_CURRENT_PATH = "/var/snap/charmed-postgresql/current"

tests/unit/test_charm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ def test_restart(self, _are_all_members_ready, _restart_postgresql):
10161016
@patch("charm.snap.SnapCache")
10171017
@patch("charms.rolling_ops.v0.rollingops.RollingOpsManager._on_acquire_lock")
10181018
@patch("charm.Patroni.reload_patroni_configuration")
1019-
@patch("charm.Patroni.update_parameter_controller_by_patroni")
1019+
@patch("charm.Patroni.bulk_update_parameters_controller_by_patroni")
10201020
@patch("charm.PostgresqlOperatorCharm._validate_config_options")
10211021
@patch("charm.Patroni.member_started", new_callable=PropertyMock)
10221022
@patch("charm.PostgresqlOperatorCharm._is_workload_running", new_callable=PropertyMock)

0 commit comments

Comments
 (0)