diff --git a/src/charm.py b/src/charm.py index 9dae00059..4e09b693f 100755 --- a/src/charm.py +++ b/src/charm.py @@ -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.""" @@ -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: diff --git a/templates/dispatch-event.service.j2 b/templates/dispatch-event.service.j2 index b4482795f..8908f048f 100644 --- a/templates/dispatch-event.service.j2 +++ b/templates/dispatch-event.service.j2 @@ -4,7 +4,7 @@ Description=Dispatch the {{event}} event on {{unit}} [Service] Type=oneshot # For juju 3 and juju 2 compatibility. The juju-run binary was renamed to juju-exec for juju 3. -ExecStart=/usr/bin/timeout "{{timeout}}" /usr/bin/run-one /usr/bin/bash -c '/usr/bin/juju-exec "{{unit}}" "JUJU_DISPATCH_PATH={{event}} ./dispatch" || /usr/bin/juju-run "{{unit}}" "JUJU_DISPATCH_PATH={{event}} ./dispatch"' +ExecStart=/usr/bin/timeout "{{timeout}}" /usr/bin/run-one /usr/bin/bash -c '/usr/bin/juju-exec "{{unit}}" "JUJU_DISPATCH_PATH={{event}} /usr/bin/timeout {{timeout}} ./dispatch" || /usr/bin/juju-run "{{unit}}" "JUJU_DISPATCH_PATH={{event}} /usr/bin/timeout {{timeout}} ./dispatch"' [Install] WantedBy=multi-user.target