Skip to content

Commit

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

Expand All @@ -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."""

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

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

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

0 comments on commit 5b37d61

Please sign in to comment.