Skip to content

Commit

Permalink
log juju processes in update-status
Browse files Browse the repository at this point in the history
  • Loading branch information
cbartz committed Sep 19, 2024
1 parent 9a9e740 commit b6d41f5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,22 @@ def _ensure_reconcile_timer_is_active(self) -> None:
logger.error("Reconciliation event timer is not activated")
self._set_reconcile_timer()

@staticmethod
def _log_juju_processes() -> None:
"""Log the running Juju processes.
Log all processes with 'juju' in the command line.
"""
try:
processes, _ = execute_command(
["ps", "afuwwx"],
check_exit=True,
)
juju_processes = "\n".join(line for line in processes.splitlines() if "juju" in line)
logger.info("Juju processes: %s", juju_processes)
except SubprocessError:
logger.exception("Failed to get Juju processes")

@catch_charm_errors
def _on_upgrade_charm(self, _: UpgradeCharmEvent) -> None:
"""Handle the update of charm."""
Expand Down Expand Up @@ -898,6 +914,7 @@ def _on_update_dependencies_action(self, event: ActionEvent) -> None:
def _on_update_status(self, _: UpdateStatusEvent) -> None:
"""Handle the update of charm status."""
self._ensure_reconcile_timer_is_active()
self._log_juju_processes()

@catch_charm_errors
def _on_stop(self, _: StopEvent) -> None:
Expand Down

0 comments on commit b6d41f5

Please sign in to comment.