Skip to content

refactor: preserve exit code in ocppi CommandFailedError - #2181

Merged
ComixHe merged 1 commit into
OpenAtom-Linyaps:masterfrom
wrj97-alt:agent/bot/9da0b62856e7
Oct 16, 2026
Merged

ComixHe merged 1 commit into
OpenAtom-Linyaps:masterfrom
wrj97-alt:agent/bot/9da0b62856e7

Conversation

@wrj97-alt

Copy link
Copy Markdown

Summary

Refactor ocppi CommandFailedError to preserve the process exit code, so ll-cli enter can return the real exit code of the command executed inside the container.

Related Multica issue: LL-39

Changes

  • CommandFailedError.hpp: Added ret_ member and exitStatus() accessor; what() message now shows the converted exit code instead of raw wait() status.
  • cli.cpp (Cli::enter): Catches CommandFailedError and returns e.exitStatus() as the process exit code; other exceptions still return -1.
  • cli.cpp (Cli::reuseContainer): Uses exitStatus() via _exit(e.exitStatus()) instead of collapsing to EXIT_FAILURE, resolving the existing TODO.
  • common_cli_test.cpp: Added ExecPreservesCommandExitStatus test verifying exit code 42 is correctly preserved.

@deepin-ci-robot

Copy link
Copy Markdown
Collaborator

Hi @wrj97-alt. Thanks for your PR.

I'm waiting for a OpenAtom-Linyaps member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
libs/linglong/src/linglong/cli/cli.cpp 0.00% 10 Missing ⚠️
Files with missing lines Coverage Δ
libs/linglong/src/linglong/cli/cli.cpp 5.05% <0.00%> (-0.02%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

1. Add ret_ member and exitStatus() accessor to CommandFailedError
2. Convert raw wait() status to real exit code via WEXITSTATUS/WTERMSIG+128
3. Cli::enter catches CommandFailedError and returns the preserved exit code
4. Cli::reuseContainer uses exitStatus() instead of collapsing to EXIT_FAILURE
5. Add ExecPreservesCommandExitStatus test verifying exit code 42 is preserved

Influence:
1. Test ll-cli enter with a command that exits non-zero, verify exit code matches
2. Test ll-cli enter with a command killed by signal, verify signal+128 exit code
3. Test container reuse scenario preserves the real command exit code
4. Run CommonCLITest.* to verify all existing and new test cases pass

refactor: 保留 ocppi CommandFailedError 中的退出码

1. 为 CommandFailedError 新增 ret_ 成员和 exitStatus() 访问器
2. 通过 WEXITSTATUS/WTERMSIG+128 将 wait() 原始状态转换为真实退出码
3. Cli::enter 捕获 CommandFailedError 并返回保留的退出码
4. Cli::reuseContainer 使用 exitStatus() 替代直接折叠为 EXIT_FAILURE
5. 新增 ExecPreservesCommandExitStatus 测试,验证退出码 42 被正确保留

Influence:
1. 测试 ll-cli enter 执行非零退出码命令,验证退出码一致
2. 测试 ll-cli enter 执行被信号杀死的命令,验证返回信号码+128
3. 测试容器复用场景下真实命令退出码的保留
4. 运行 CommonCLITest.* 验证已有及新增测试用例全部通过
@wrj97-alt
wrj97-alt force-pushed the agent/bot/9da0b62856e7 branch from 2e51833 to 46822ea Compare October 15, 2026 13:33
@reddevillg
reddevillg marked this pull request as ready for review October 16, 2026 05:19
@ComixHe
ComixHe merged commit 1821fe1 into OpenAtom-Linyaps:master Oct 16, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants