Skip to content

fix(youki): print the error of a failed exec or run to stderr with --log - #3949

Open
saku3 wants to merge 1 commit into
youki-dev:mainfrom
saku3:fix/report-error-to-stderr-with-log
Open

saku3 wants to merge 1 commit into
youki-dev:mainfrom
saku3:fix/report-error-to-stderr-with-log

Conversation

@saku3

@saku3 saku3 commented Nov 29, 2026

Copy link
Copy Markdown
Member

Description

With --log <file>, tracing writes only to that file. exec and run leave through process::exit instead of returning the error from main, so when they failed nothing was written to stderr. conmon falls back to the runtime's stderr when it cannot use the log file, so podman exec showed "no logs from conmon" instead of the reason.

Print the error to stderr as well when the log goes to a file, as runc and crun do. Without --log the log is already stderr, so the output there does not change.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test updates
  • CI/CD related changes
  • Other (please describe):

Testing

  • Added new unit tests
  • Added new integration tests
  • Ran existing test suite
  • Tested manually (please provide steps)

Please specify a nonexistent command in the args field of the config.

    "args": [
      "invalid"
    ],

youki

Before this change, no error message was displayed. After this change, the following error message is displayed.

$ sudo youki --log /var/tmp/errlog/run.json --log-format json run  container
Error: failed to create container: exec process failed with error executable 'invalid' not found in $PATH

runc

$ sudo runc --log /var/tmp/errlog/run.json --log-format json run container
runc run failed: unable to start container process: error during container init: exec: "invalid": executable file not found in $PATH

Related Issues

Related #3670

Additional Context

This change addresses error reporting for podman exec. The error reporting issue with podman run is separate.

As discussed in #3670, older versions of Podman fail to parse the runtime log when youki writes multiple JSON objects to the log file.

This issue has already been addressed on the Podman side in podman-container-tools/podman#29026, although the fix is not yet included in v6.2.1.

Signed-off-by: Yusuke Sakurai <yusuke.sakurai@3-shake.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the changes that expose command failures on stderr when logs are redirected.

No open issues 🎉

What changed in this PR

This PR improves error reporting for failed youki exec and youki run commands when --log redirects logs to a file, allowing callers such as conmon to obtain the failure reason from stderr.

Changes:

  • Adds a shared error-reporting helper that preserves logging and also prints to stderr when --log is set.
  • Adds regression tests for both commands, checking file logging and ensuring errors appear only once on stderr without --log.
File Description
crates/​youki/​tests/​error_output.rs Tests error output with and without a log file using invalid container IDs.
crates/​youki/​src/​main.rs Shares error reporting between exec and run and adds stderr output when logging to a file.

Review effort: Balanced

@saku3
saku3 requested a review from a team November 29, 2026 09:45

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants