fix: use runuser for privilege drop and capture container stderr in logs
The container still exited immediately after the su-based fix. can interfere with TTY/stdin handling for interactive shells. Switch to , which is root-only, skips PAM, and preserves file descriptors so bash stays interactive. Also improve container failure diagnostics: - now combines stdout and stderr - This helps surface the real reason when a container exits with code 0 Quality gates: - pytest tests/unit: 219 passed - ruff: clean on changed files - mypy: clean on changed files
This commit is contained in:
@@ -283,7 +283,7 @@ def get_container_logs(container_id: str, tail: int = 100) -> str:
|
||||
tail: Number of lines to return
|
||||
|
||||
Returns:
|
||||
Container logs
|
||||
Container logs (stdout + stderr)
|
||||
"""
|
||||
result = subprocess.run(
|
||||
["docker", "logs", "--tail", str(tail), container_id],
|
||||
@@ -291,9 +291,15 @@ def get_container_logs(container_id: str, tail: int = 100) -> str:
|
||||
text=True,
|
||||
)
|
||||
|
||||
if result.returncode == 0:
|
||||
return result.stdout
|
||||
return f"Failed to get logs: {result.stderr}"
|
||||
if result.returncode != 0:
|
||||
return f"Failed to get logs: {result.stderr}"
|
||||
|
||||
logs = result.stdout
|
||||
if result.stderr:
|
||||
if logs:
|
||||
logs += "\n"
|
||||
logs += f"STDERR:\n{result.stderr}"
|
||||
return logs
|
||||
|
||||
|
||||
def find_free_port(start: int = 10000, end: int = 20000) -> int:
|
||||
|
||||
Reference in New Issue
Block a user