fix(analyze): return integer exit code from analyze_boot#6863
fix(analyze): return integer exit code from analyze_boot#6863nanookclaw wants to merge 1 commit into
Conversation
|
Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close. If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging blackboxsw, and he will ensure that someone takes a look soon. (If the pull request is closed and you would like to continue working on it, please do tag blackboxsw to reopen it.) |
|
Canonical CLA is now signed for |
analyze_boot returned a string status_code ("successful", "failure",
"container") which sys.exit() interpreted as exit code 1, printing the
string to stderr. This caused -- Most Recent Boot Record --
Kernel Started at: 2026-04-16 04:48:35.716519+00:00
Kernel ended boot at: 2026-04-16 04:48:38.956376+00:00
Kernel time to boot (seconds): 3.2398569583892822
Cloud-init activated by systemd at: 2026-04-16 04:48:35.716519+00:00
Time between Kernel end boot and Cloud-init activation (seconds): -3.2398569583892822
Cloud-init start: 2024-11-20 00:52:10.535000+00:00 to always exit
with return code 1, even on successful analysis.
Return 0 for success/container and 1 for failure instead.
477e6d9 to
02aeed5
Compare
|
Rebased onto current The earlier The PR's workflows are currently in |
Problem
cloud-init analyze bootalways exits with return code 1, even on successful analysis.The user reports
return_code=1withstderr=successful, which is the symptom.Root Cause
analyze_bootreturns a string status code ("successful","failure", or"container"). This return value flows throughsub_main→main→sys.exit(). In Python,sys.exit(string)prints the string to stderr and exits with code 1 — even when the string is"successful".Fix
Return an integer exit code instead of the string status code:
0forSUCCESS_CODEandCONTAINER_CODE(analysis succeeded)1forFAIL_CODE(analysis failed)This is consistent with the other analyze subcommands (
analyze_blame,analyze_show,analyze_dump) which all returnNone, whichsys.exit()correctly treats as exit code 0.Testing
Updated
tests/unittests/analyze/test_boot.py:test_container_no_ci_log_line: asserts1 == finish_code(wasFAIL_CODE)test_container_ci_log_line: asserts0 == finish_code(wasCONTAINER_CODE)Fixes #4245