From 7a80edb9cf32b71304afa46634f44f442544453e Mon Sep 17 00:00:00 2001 From: Kian Parvin Date: Fri, 28 Jul 2023 16:24:45 +0200 Subject: [PATCH] Rename Defer exception --- charms/jimm-k8s/src/charm.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/charms/jimm-k8s/src/charm.py b/charms/jimm-k8s/src/charm.py index 8a5bd5504..57148f368 100755 --- a/charms/jimm-k8s/src/charm.py +++ b/charms/jimm-k8s/src/charm.py @@ -74,8 +74,9 @@ PROMETHEUS_PORT = 8080 -class DeferRequiredError(Exception): - """Used to indicate to the calling function that an event should be deferred.""" +class DeferError(Exception): + """Used to indicate to the calling function that an event could be deferred + if the hook needs to be retried.""" pass @@ -322,7 +323,7 @@ def _update_workload(self, event): else: logger.info("workload not ready - returning") return - except DeferRequiredError: + except DeferError: logger.info("workload container not ready - deferring") event.defer() return @@ -351,7 +352,7 @@ def _on_stop(self, _): logger.info("failed to stop the jimm service: {}".format(e)) try: self._ready() - except DeferRequiredError: + except DeferError: logger.info("workload not ready") return @@ -363,7 +364,7 @@ def _on_update_status(self, _): return try: self._ready() - except DeferRequiredError: + except DeferError: logger.info("workload not ready") return @@ -434,7 +435,7 @@ def _ready(self): self.unit.status = WaitingStatus("stopped") return True else: - raise DeferRequiredError + raise DeferError def _get_network_address(self, event): return str(self.model.get_binding(event.relation).network.egress_subnets[0].network_address)