Skip to content

Commit

Permalink
Handle ModelError that is raised when service does not exist (#27)
Browse files Browse the repository at this point in the history
* Handle ModelError that is raised when service does not exist

* Add log
  • Loading branch information
kian99 committed Sep 28, 2023
1 parent 407753c commit 05fed1d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion charms/openfga-k8s/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,12 @@ def is_openfga_server_running(self) -> bool:
if not container.can_connect():
logger.error(f"Cannot connect to container {WORKLOAD_CONTAINER}")
return False
if not container.get_service(SERVICE_NAME).is_running():
try:
svc = container.get_service(SERVICE_NAME)
except ModelError:
logger.error(f"{SERVICE_NAME} is not running")
return False
if not svc.is_running():
logger.error(f"{SERVICE_NAME} is not running")
return False
return True
Expand Down

0 comments on commit 05fed1d

Please sign in to comment.