fix(analyze): return integer exit code from analyze_boot#6863
Open
nanookclaw wants to merge 1 commit intocanonical:mainfrom
Open
fix(analyze): return integer exit code from analyze_boot#6863nanookclaw wants to merge 1 commit intocanonical:mainfrom
nanookclaw wants to merge 1 commit intocanonical:mainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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