Skip to content

cmd/status: add --timeout to cloud-init status --wait#6796

Open
koushik717 wants to merge 4 commits intocanonical:mainfrom
koushik717:feature/status-wait-timeout
Open

cmd/status: add --timeout to cloud-init status --wait#6796
koushik717 wants to merge 4 commits intocanonical:mainfrom
koushik717:feature/status-wait-timeout

Conversation

@koushik717
Copy link
Copy Markdown

@koushik717 koushik717 commented Mar 17, 2026

Proposed Changes

Add an optional --timeout SECONDS argument to cloud-init status --wait.

When --timeout is given and cloud-init has not finished within that period, the command exits with return code 1 and prints:

Timed out waiting for cloud-init to complete after Xs

When --timeout is 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_timeout finishes before deadline, exits 0
    • test_status_wait_timeout_expires deadline exceeded, exits 1 with message
    • test_status_wait_no_timeout_unchanged no --timeout passed, original behavior preserved
      All 47 tests in the status test suite pass.

Notes

Help text for --timeout includes the warning requested in the issue:

"Note: using --timeout means cloud-init may not have completed configuration at exit."

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
@holmanb holmanb self-assigned this Mar 17, 2026
- 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.
@koushik717 koushik717 force-pushed the feature/status-wait-timeout branch from 2f9fdce to f2b38ad Compare March 18, 2026 00:53
@holmanb
Copy link
Copy Markdown
Member

holmanb commented Mar 18, 2026

What is your use case? Is there something that this accomplishes that you cannot achieve with something like the timeout utility? Please see my latest comment on the linked bug.

@koushik717
Copy link
Copy Markdown
Author

What is your use case? Is there something that this accomplishes that you cannot achieve with something like the timeout utility? Please see my latest comment on the linked bug.

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.
The timeout utility gets close but has a few issues: it exits with code 124 which conflicts with cloud-init’s existing exit codes and makes script error handling messy. It also isn’t available in all environments where cloud-init runs, particularly minimal containers. And since wait polls at intervals, timeout can fire a SIGTERM mid-poll rather than between cycles, which is less clean.
A native flag handles all of this and is self-contained and discoverable via help. That said, I saw your comment on the linked bug and happy to rework the approach if you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --timeout to cloud-init status --wait

2 participants