Skip to content

Commit

Permalink
fix: raise on addon list failure
Browse files Browse the repository at this point in the history
  • Loading branch information
yanksyoon committed Sep 12, 2023
1 parent 7974de7 commit 804d342
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,13 @@ def _addon_reconciliation(self, addon_type: str) -> None:
"""
self._check_addon_type(addon_type)
logger.info("Start %s reconciliation process", addon_type)
current_installed_addons = set(t["name"] for t in self._wp_addon_list(addon_type).result)
exec_result = self._wp_addon_list(addon_type)
if not exec_result.success:
logger.error("Failed to list addons, %s", exec_result.message)
raise exceptions.WordPressStatusException("Failed to list addons.")
if not exec_result.result:
return
current_installed_addons = set(t["name"] for t in exec_result.result)
logger.debug("Currently installed %s %s", addon_type, current_installed_addons)
addons_in_config = [
t.strip() for t in self.model.config[f"{addon_type}s"].split(",") if t.strip()
Expand All @@ -903,15 +909,15 @@ def _addon_reconciliation(self, addon_type: str) -> None:
uninstall_addons = current_installed_addons - desired_addons
for addon in install_addons:
logger.info("Install %s: %s", addon_type, repr(addon))
result = self._wp_addon_install(addon_type=addon_type, addon_name=addon)
if not result.success:
exec_result = self._wp_addon_install(addon_type=addon_type, addon_name=addon)
if not exec_result.success:
raise exceptions.WordPressBlockedStatusException(
f"failed to install {addon_type} {repr(addon)}"
)
for addon in uninstall_addons:
logger.info("Uninstall %s: %s", addon_type, repr(addon))
result = self._wp_addon_uninstall(addon_type=addon_type, addon_name=addon)
if not result.success:
exec_result = self._wp_addon_uninstall(addon_type=addon_type, addon_name=addon)
if not exec_result.success:
raise exceptions.WordPressBlockedStatusException(
f"failed to uninstall {addon_type} {repr(addon)}"
)
Expand Down

0 comments on commit 804d342

Please sign in to comment.