From e284b6cd70d9bf957226d0e0991afe66d0f52a8e Mon Sep 17 00:00:00 2001 From: Lucas Gameiro Date: Mon, 5 Aug 2024 11:12:31 -0300 Subject: [PATCH] remove deprecated config option (#608) --- config.yaml | 10 +--------- src/charm.py | 7 ------- tests/unit/test_charm.py | 18 +----------------- 3 files changed, 2 insertions(+), 33 deletions(-) diff --git a/config.yaml b/config.yaml index f38e57a952..2a3cad8c17 100644 --- a/config.yaml +++ b/config.yaml @@ -311,20 +311,12 @@ options: minimal running performance. type: string default: "production" - profile-limit-memory: - type: int - description: | - [DEPRECTATED] Use profile_limit_memory instead. Amount of memory in Megabytes to limit PostgreSQL - and associated process to. If unset, this will be decided according to the default memory limit - in the selected profile. Only comes into effect when the `production` profile is selected. This - config option cannot be set at the same time as profile_limit_memory. profile_limit_memory: type: int description: | Amount of memory in Megabytes to limit PostgreSQL and associated process to. If unset, this will be decided according to the default memory limit in the selected profile. - Only comes into effect when the `production` profile is selected. This config option cannot be - set at the same time as profile-limit-memory. + Only comes into effect when the `production` profile is selected. request_date_style: description: | Sets the display format for date and time values. Allowed formats are explained diff --git a/src/charm.py b/src/charm.py index c5dff988d8..7bae5a3b84 100755 --- a/src/charm.py +++ b/src/charm.py @@ -1709,13 +1709,6 @@ def _can_connect_to_postgresql(self) -> bool: def update_config(self, is_creating_backup: bool = False) -> bool: """Updates Patroni config file based on the existence of the TLS files.""" # Retrieve PostgreSQL parameters. - if ( - self.model.config.get("profile-limit-memory") is not None - and self.model.config.get("profile_limit_memory") is not None - ): - raise ValueError( - "Both profile-limit-memory and profile_limit_memory are set. Please use only one of them." - ) if self.config.profile_limit_memory: limit_memory = self.config.profile_limit_memory * 10**6 else: diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py index 9667e3f43f..acde94d57b 100644 --- a/tests/unit/test_charm.py +++ b/tests/unit/test_charm.py @@ -1608,27 +1608,11 @@ def test_update_config(harness): harness.set_can_connect(POSTGRESQL_CONTAINER, True) harness.add_relation("upgrade", harness.charm.app.name) postgresql_mock.is_tls_enabled = PropertyMock(side_effect=[False, False, False, False]) - _is_workload_running.side_effect = [False, False, True, True, False, True] + _is_workload_running.side_effect = [True, True, False, True] _member_started.side_effect = [True, True, False] postgresql_mock.build_postgresql_parameters.return_value = {"test": "test"} - # Test when only one of the two config options for profile limit memory is set. - harness.update_config({"profile-limit-memory": 1000}) - harness.charm.update_config() - - # Test when only one of the two config options for profile limit memory is set. - harness.update_config({"profile_limit_memory": 1000}, unset={"profile-limit-memory"}) - harness.charm.update_config() - - # Test when the two config options for profile limit memory are set at the same time. - _render_patroni_yml_file.reset_mock() - harness.update_config({"profile-limit-memory": 1000}) - with pytest.raises(ValueError): - harness.charm.update_config() - assert False - # Test without TLS files available. - harness.update_config(unset={"profile-limit-memory", "profile_limit_memory"}) with harness.hooks_disabled(): harness.update_relation_data(rel_id, harness.charm.unit.name, {"tls": ""}) _is_tls_enabled.return_value = False