Skip to content

Commit

Permalink
Add configuration update on upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
marceloneppel committed Oct 13, 2023
1 parent 491e6a6 commit a3c86bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ def _on_upgrade_charm_check_legacy(self) -> None:
@override
def _on_upgrade_granted(self, event: UpgradeGrantedEvent) -> None:
# Refresh the charmed PostgreSQL snap and restart the database.
# Update the configuration.
self.charm.unit.status = MaintenanceStatus("updating configuration")
self.charm.update_config()

self.charm.unit.status = MaintenanceStatus("refreshing the snap")
self.charm._install_snap_packages(packages=SNAP_PACKAGES, refresh=True)

Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ def test_log_rollback(self, mock_logging, _update_config):
@patch("charm.PostgresqlOperatorCharm._setup_exporter")
@patch("charm.Patroni.start_patroni")
@patch("charm.PostgresqlOperatorCharm._install_snap_packages")
@patch("charm.PostgresqlOperatorCharm.update_config")
def test_on_upgrade_granted(
self,
_update_config,
_install_snap_packages,
_start_patroni,
_setup_exporter,
Expand All @@ -80,6 +82,7 @@ def test_on_upgrade_granted(
mock_event = MagicMock()
_start_patroni.return_value = False
self.charm.upgrade._on_upgrade_granted(mock_event)
_update_config.assert_called_once()
_install_snap_packages.assert_called_once_with(packages=SNAP_PACKAGES, refresh=True)
_member_started.assert_not_called()
mock_event.defer.assert_not_called()
Expand Down

0 comments on commit a3c86bd

Please sign in to comment.