Service: Wait for LXD members to be ready after join#1246
Merged
roosterfish merged 3 commits intocanonical:mainfrom Mar 10, 2026
Merged
Service: Wait for LXD members to be ready after join#1246roosterfish merged 3 commits intocanonical:mainfrom
roosterfish merged 3 commits intocanonical:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR reduces post-cluster-join race conditions by ensuring LXD is responsive before returning from the join workflow, and adjusts the test harness so LXD is force-started after snapshot restores.
Changes:
- Add a post-
Joinreadiness wait (viainternal/ready) before returning fromLXDService.Join. - Move the CI “force LXD to start” step from
reset_systemtorestore_systemso it runs after snapshot restore.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
test/includes/microcloud.sh |
Moves the “force LXD startup” step to the snapshot restore path to avoid missing it when SNAPSHOT_RESTORE=1. |
service/lxd.go |
Adds a bounded wait for LXD readiness after joining a cluster to avoid early follow-up operations hitting an unready member. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This allows reusing the same const inside the service package too. Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
This is to prevent the following error from happening in case resources are getting deployed right after creating the MicroCloud: Error: Failed instance creation: Fetch project database object: Failed to fetch from projects table: Failed to fetch from projects table: Failed to fetch from projects table: sql: transaction has already been committed or rolled back Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
When SNAPSHOT_RESTORE=1, the reset_systems func is returning early and doesn't run reset_system which does not trigger the force start of LXD. Instead perform this action in restore_system so it always runs regardless whether or not SNAPSHOT_RESTORE is set. Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
a558c50 to
a026e75
Compare
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.
We sometimes observe this error in the pipeline and it seems to be a race.
This is to prevent the following error from happening in case resources are getting deployed right after creating the MicroCloud:
Error: Failed instance creation: Fetch project database object: Failed to fetch from projects table: Failed to fetch from projects table: Failed to fetch from projects table: sql: transaction has already been committed or rolled backAn equivalent fix was once added to lxd-ci, see https://github.com/canonical/lxd-ci/pull/577/files.
In addition the force start of LXD in the pipeline is moved from
reset_systemintorestore_systemto ensure it always runs.