cmd/status: add --timeout to cloud-init status --wait#6796
cmd/status: add --timeout to cloud-init status --wait#6796koushik717 wants to merge 4 commits intocanonical:mainfrom
Conversation
Add an optional --timeout <seconds> argument to cloud-init status --wait. When --timeout is given and cloud-init has not finished within that period, exit with return code 1 and print a clear message. When --timeout is not passed, behavior is unchanged. Fixes: canonicalGH-4059
- Reformat tests/unittests/cmd/test_status.py with black (dedent style) - Shorten long docstring line to satisfy ruff E501 (max 79 chars)
Black moved the # noqa: E501 comments from the closing triple-quote lines to the closing paren lines, breaking ruff suppression. Move them back to the """ lines where ruff checks them.
2f9fdce to
f2b38ad
Compare
|
What is your use case? Is there something that this accomplishes that you cannot achieve with something like the |
My main use case is provisioning scripts and CI pipelines where cloud-init needs to finish before the next step, but hanging indefinitely isn’t acceptable. |
Proposed Changes
Add an optional
--timeout SECONDSargument tocloud-init status --wait.When
--timeoutis given and cloud-init has not finished within that period, the command exits with return code 1 and prints:When
--timeoutis not passed, behavior is completely unchanged.Closes #4059
Test Coverage
Three new unit tests added to
tests/unittests/cmd/test_status.py:test_status_wait_timeout_completes_before_timeoutfinishes before deadline, exits 0test_status_wait_timeout_expiresdeadline exceeded, exits 1 with messagetest_status_wait_no_timeout_unchangedno --timeout passed, original behavior preservedAll 47 tests in the status test suite pass.
Notes
Help text for
--timeoutincludes the warning requested in the issue: