Skip to content

Commit

Permalink
Move exporter installed check to top of update status
Browse files Browse the repository at this point in the history
  • Loading branch information
dashmage committed Mar 21, 2024
1 parent 47a403a commit 7351e70
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ def _on_update_status(self, _: EventBase) -> None: # noqa: C901
# The charm should be in BlockedStatus with install failed msg
return # type: ignore[unreachable]

if not self._stored.exporter_installed: # type: ignore[truthy-function]
# The charm should be in BlockedStatus with exporter install failed msg
return # type: ignore[unreachable]

config_valid, config_valid_message = self.validate_exporter_configs()
if not config_valid:
self.model.unit.status = BlockedStatus(config_valid_message)
Expand All @@ -143,10 +147,6 @@ def _on_update_status(self, _: EventBase) -> None: # noqa: C901
self.model.unit.status = BlockedStatus(error_msg)
return

if not self._stored.exporter_installed: # type: ignore[truthy-function]
logger.warning("Exporter not installed") # type: ignore[unreachable]
return

if not self.exporter.check_health():
logger.warning("Exporter health check - failed.")
# if restart isn't successful, an ExporterError exception will be raised here
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def test_10_config_changed(self, mock_exporter):
"""Test config change event updates the charm's internal store."""
self.harness.begin()
self.harness.charm._stored.resource_installed = True
self.harness.charm._stored.exporter_installed = True

new_config = {"exporter-port": 80, "exporter-log-level": "DEBUG"}
self.harness.update_config(new_config)
Expand Down

0 comments on commit 7351e70

Please sign in to comment.