From 7351e70e27ee32b1a91573a72f8430c508474662 Mon Sep 17 00:00:00 2001 From: Ashley James Date: Thu, 21 Mar 2024 19:05:31 +0530 Subject: [PATCH] Move exporter installed check to top of update status --- src/charm.py | 8 ++++---- tests/unit/test_charm.py | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/charm.py b/src/charm.py index 472bc11a..862d346c 100755 --- a/src/charm.py +++ b/src/charm.py @@ -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) @@ -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 diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py index f7dead20..96687ab0 100644 --- a/tests/unit/test_charm.py +++ b/tests/unit/test_charm.py @@ -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)