Skip to content

Commit

Permalink
Merge b6d41f5 into 35be8c7
Browse files Browse the repository at this point in the history
  • Loading branch information
cbartz authored Sep 19, 2024
2 parents 35be8c7 + b6d41f5 commit 1727aee
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
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
2 changes: 1 addition & 1 deletion templates/dispatch-event.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1727aee

Please sign in to comment.