fix: Add waitready command to verify cluster ready#683
Open
johnramsden wants to merge 1 commit intocanonical:mainfrom
Open
fix: Add waitready command to verify cluster ready#683johnramsden wants to merge 1 commit intocanonical:mainfrom
johnramsden wants to merge 1 commit intocanonical:mainfrom
Conversation
When an operator attempts to do something before the cluster is up they can receive unexpected failures because bootstrap is not finished or microcluster is not yet available. This can be particularly problematic in CI or scripting. Add an additional subcommand (similar to lxd waitready) https://manpages.debian.org/unstable/lxd/lxd.waitready.1 To confirm the cluster is up we check for the microcluster daemon to be ready, and for ceph to be ready (ceph -s) On failure we get a message like the following if we haven't bootstrapped for example: microceph waitready --timeout 30 Error: ceph not ready: timed out waiting for Ceph to become ready: context deadline exceeded Running the following you should expect it to wait before running status, and it should succeed sudo microceph cluster bootstrap & sudo microceph waitready sudo microceph status [1] 35966 MicroCeph deployment summary: - microceph (10.56.203.112) Services: mds, mgr, mon Disks: 0 Signed-off-by: John Ramsden <john.ramsden@canonical.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
Author
|
One note I have is I'm not sure if |
sabaini
requested changes
Mar 2, 2026
Collaborator
sabaini
left a comment
There was a problem hiding this comment.
Hey @johnramsden thank you, lgtm in general, two comments inline
| // It retries every second until success or the context is cancelled/expired. | ||
| func WaitForCephReady(ctx context.Context) error { | ||
| for { | ||
| _, err := common.ProcessExec.RunCommand("ceph", "-s") |
Collaborator
There was a problem hiding this comment.
Hm, a hanging ceph -s could hang this forever, not sure how often this occurs in practice but just for robustness could use the cephRunContext() function and pass in the ctx
| } | ||
|
|
||
| ctx := context.Background() | ||
| if c.flagTimeout > 0 { |
Collaborator
There was a problem hiding this comment.
Minor nit: should we be erroring out if operators pass in a neg. timeout value?
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.
Description
When an operator attempts to do something before the cluster is up they can receive unexpected failures because bootstrap is not finished or microcluster is not yet available. This can be particularly problematic in CI or scripting.
Add an additional subcommand (similar to lxd waitready) https://manpages.debian.org/unstable/lxd/lxd.waitready.1
To confirm the cluster is up we check for the microcluster daemon to be ready, and for ceph to be ready (ceph -s)
On failure we get a message like the following if we haven't bootstrapped for example:
Running the following you should expect it to wait before running status, and it should succeed
Fixes #653
Type of change
Delete options that are not relevant.
How has this been tested?
Added tests demonstrating waiting and timeout prior to bootstrap, and waiting succeeding post bootstrap.
Contributor checklist
Please check that you have: