fix(ci): show deploy stdout/stderr and pass inventory_dir in run orchestrator

- Capture and print deploy stdout/stderr on failure (development/deploy.py)
- Forward INVENTORY_DIR into init and deploy handlers (development/run.py)
- Add missing when_down flag for up handler
- Print full traceback on orchestrator failure for CI visibility

https://chatgpt.com/share/6970fcf5-5860-800f-89ae-0d601405489b
This commit is contained in:
kevinveenbirkenbach committed 2026-01-21 17:21:02 +01:00
1 parent a89f74fac0
commit bdd6587bcc
2 files changed
+30 -5

No files matched your search

+10 -2
View File
@@ -38,11 +38,19 @@ def _run_deploy(
if debug:
cmd.insert(cmd.index("-T"), "--debug")
# Forward native ansible-playbook flags (via dedicated wrapper passthrough)
if passthrough:
cmd.extend(passthrough)
r = compose.exec(cmd, check=False)
# IMPORTANT: capture output so we can show it on failure
r = compose.exec(cmd, check=False, capture=True)
if r.returncode != 0:
print("===== deploy stdout =====")
print((r.stdout or "").rstrip() or "<empty>")
print("===== deploy stderr =====")
print((r.stderr or "").rstrip() or "<empty>")
print("=========================")
return int(r.returncode)
+20 -3
View File
@@ -2,12 +2,14 @@ from __future__ import annotations
import argparse
import os
import sys
import traceback
from pathlib import Path
from .common import make_compose, resolve_deploy_ids_for_app
from .deploy import handler as deploy_handler
from .init import handler as init_handler
from .log_utils import append_text, log_path, write_text
from .common import make_compose, resolve_deploy_ids_for_app
from .up import handler as up_handler
@@ -67,20 +69,26 @@ def handler(args: argparse.Namespace) -> int:
f"deploy_type={args.type}\ndistro={args.distro}\napp={args.app}\ndebug={args.debug}\n",
)
exit_code = 0
# Drop leading '--' from REMAINDER
passthrough = list(args.ansible_args or [])
if passthrough and passthrough[0] == "--":
passthrough = passthrough[1:]
# Inventory dir is required for init+deploy (both default to $INVENTORY_DIR)
inv_dir = os.environ.get("INVENTORY_DIR")
if not inv_dir:
raise SystemExit("INVENTORY_DIR must be set for run (used by init/deploy)")
inv_dir = str(inv_dir).rstrip("/")
compose = None
exit_code = 0
try:
# 1) up (re-use up handler so build-missing stays SPOT)
class _UpArgs:
distro = args.distro
skip_entry_init = bool(args.skip_entry_init)
when_down = False # required by up.handler()
rc_up = int(up_handler(_UpArgs()))
if rc_up != 0:
@@ -98,6 +106,7 @@ def handler(args: argparse.Namespace) -> int:
distro = args.distro
app = args.app
include = None
inventory_dir = inv_dir
threshold_gib = 100
force_storage_constrained = None
@@ -109,6 +118,7 @@ def handler(args: argparse.Namespace) -> int:
type = args.type
app = args.app
id = None
inventory_dir = inv_dir
debug = bool(args.debug)
ansible_args = ["--", *passthrough] if passthrough else []
@@ -129,10 +139,17 @@ def handler(args: argparse.Namespace) -> int:
)
return exit_code
except Exception as exc:
exit_code = 1
# Make the failure visible in CI output (not only in logs file)
print(f">>> ERROR: {exc}", file=sys.stderr)
traceback.print_exc()
append_text(main_log, f"\nERROR: {exc}\n")
return 1
finally:
should_keep = bool(args.keep_stack_on_failure) and exit_code != 0
if not should_keep and compose is not None: