From 33b3c8fbebad8ae4716f76944b9747f5b89b816e Mon Sep 17 00:00:00 2001 From: Kian Parvin Date: Fri, 28 Jul 2023 15:42:39 +0200 Subject: [PATCH] linting fix --- charms/jimm-k8s/src/charm.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/charms/jimm-k8s/src/charm.py b/charms/jimm-k8s/src/charm.py index f8aa607b2..8a5bd5504 100755 --- a/charms/jimm-k8s/src/charm.py +++ b/charms/jimm-k8s/src/charm.py @@ -46,7 +46,7 @@ ) from ops.charm import ActionEvent, CharmBase, RelationJoinedEvent from ops.main import main -from ops.model import ActiveStatus, BlockedStatus, WaitingStatus, ErrorStatus +from ops.model import ActiveStatus, BlockedStatus, ErrorStatus, WaitingStatus from state import State, requires_state, requires_state_setter @@ -73,10 +73,13 @@ # This likely will just be JIMM's port. PROMETHEUS_PORT = 8080 -class DeferException(Exception): + +class DeferRequiredError(Exception): """Used to indicate to the calling function that an event should be deferred.""" + pass + class JimmOperatorCharm(CharmBase): """JIMM Operator Charm.""" @@ -319,7 +322,7 @@ def _update_workload(self, event): else: logger.info("workload not ready - returning") return - except DeferException: + except DeferRequiredError: logger.info("workload container not ready - deferring") event.defer() return @@ -348,7 +351,7 @@ def _on_stop(self, _): logger.info("failed to stop the jimm service: {}".format(e)) try: self._ready() - except DeferException: + except DeferRequiredError: logger.info("workload not ready") return @@ -360,7 +363,7 @@ def _on_update_status(self, _): return try: self._ready() - except DeferException: + except DeferRequiredError: logger.info("workload not ready") return @@ -431,7 +434,7 @@ def _ready(self): self.unit.status = WaitingStatus("stopped") return True else: - raise DeferException + raise DeferRequiredError def _get_network_address(self, event): return str(self.model.get_binding(event.relation).network.egress_subnets[0].network_address)