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. |
|
Hi @blackboxsw just saw the stale notice. I'm still actively interested in getting this merged. Happy to rebase, address any review feedback, or make any changes needed. Would appreciate a look when you get a chance. Thanks! |
- Schema-driven forms for 8 cloud-init modules (users, packages, runcmd, write_files, ssh, hostname, timezone, ntp) - Real-time YAML output with Monaco Editor starting with #cloud-config - Client-side validation with Ajv against official cloud-init JSON schema - Server-side validation via FastAPI backend - 5 built-in templates: Ubuntu Server, Docker Host, Kubernetes Node, Web Server, Developer Workstation - Shareable config links via lz-string URL encoding - Full keyboard navigation and ARIA accessibility - axe-core accessibility tests in CI - Built with @canonical/react-components (Vanilla Framework) - Motivated by canonical/cloud-init#6796 and canonical/react-components#1339
|
Hello @koushik717, I'm not fully convinced of the avoidance of script complexity by introducing a If we were to provide a
If we moved forward with this feature, under the premise of supporting minimal images support which don't have access to coreutils, I would want to:
|
|
Thanks for the detailed feedback @blackboxsw . |
Before you said that error handling with different error codes was the problem you were trying to solve. Now you agree that If you have a platform without cloud-init status --wait & pid=$!; (sleep 30; kill $pid 2>/dev/null) & watcher=$!; wait $pid 2>/dev/null; kill $watcher 2>/dev/nullFor how trivial this is to do with |
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: