Skip to content

Commit

Permalink
Rename Defer exception
Browse files Browse the repository at this point in the history
  • Loading branch information
kian99 committed Jul 28, 2023
1 parent 33b3c8f commit 7a80edb
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions charms/jimm-k8s/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -363,7 +364,7 @@ def _on_update_status(self, _):
return
try:
self._ready()
except DeferRequiredError:
except DeferError:
logger.info("workload not ready")
return

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 7a80edb

Please sign in to comment.