Skip to content

Commit

Permalink
Log compose errors to a separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicaj committed Sep 10, 2024
1 parent 127109f commit ca6dff6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/middlewared/middlewared/plugins/apps/compose_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import itertools
import logging
import typing

from middlewared.service_exception import CallError
Expand All @@ -7,6 +8,9 @@
from .utils import PROJECT_PREFIX, run


logger = logging.getLogger('app_lifecycle')


def compose_action(
app_name: str, app_version: str, action: typing.Literal['up', 'down', 'pull'], *,
force_recreate: bool = False, remove_orphans: bool = False, remove_images: bool = False,
Expand Down Expand Up @@ -49,4 +53,7 @@ def compose_action(
# TODO: We will likely have a configurable timeout on this end
cp = run(['docker', 'compose'] + compose_files + args, timeout=1200)
if cp.returncode != 0:
raise CallError(f'Failed {action!r} action for {app_name!r} app: {cp.stderr}')
logger.error('Failed %r action for %r app: %s', action, app_name, cp.stderr)
raise CallError(
f'Failed {action!r} action for {app_name!r} app, please check /var/log/app_lifecycle.log for more details'
)

0 comments on commit ca6dff6

Please sign in to comment.