Skip to content

Commit

Permalink
[DPE-4889] Remove deprecated config option profile-limit-memory (#564)
Browse files Browse the repository at this point in the history
* remove deprecated config option

* update config description

* update charm code
  • Loading branch information
lucasgameiroborges authored Aug 5, 2024
1 parent 25bb1ba commit 1ae5cef
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 33 deletions.
10 changes: 1 addition & 9 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1614,14 +1614,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."""
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."
)

enable_tls = self.is_tls_enabled
limit_memory = None
if self.config.profile_limit_memory:
Expand Down
17 changes: 1 addition & 16 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1268,26 +1268,11 @@ def test_update_config(harness):
rel_id = harness.model.get_relation(PEER).id
# Mock some properties.
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()

# 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
Expand Down

0 comments on commit 1ae5cef

Please sign in to comment.