LXD race condition when packing multiple charms simultaneously
Metadata
Current evaluation
Fixed in charmcraft and craft-providers. Parallel LXD commands like lxc project create and lxc copy caused race conditions during simultaneous charm packing. Concurrency controls resolved the issue in charmcraft edge and candidate 2.4.0.
Suggested action: —
No scores available.
Issue body
### Bug Description
When we run our CI we get following error:
```
Traceback (most recent call last):
File "/home/runner/work/kfp-operators/kfp-operators/tests/integration/test_bundle.py", line 39, in test_build_and_deploy
built_charms = await ops_test.build_charms(*charms_to_build.values())
File "/home/runner/work/kfp-operators/kfp-operators/.tox/bundle-integration/lib/python3.8/site-packages/pytest_operator/plugin.py", line 1028, in build_charms
charms = await asyncio.gather(
File "/home/runner/work/kfp-operators/kfp-operators/.tox/bundle-integration/lib/python3.8/site-packages/pytest_operator/plugin.py", line 1011, in build_charm
raise RuntimeError(
RuntimeError: Failed to build charm /home/runner/work/kfp-operators/kfp-operators/charms/kfp-viz:
Packing the charm.
Launching environment to pack for base name='ubuntu' channel='20.04' architectures=['amd64'] (may take a while the first time but it's reusable)
charmcraft internal error: LXDError(brief="Failed to create project 'charmcraft'.", details='* Command that failed: \'lxc --project charmcraft project create local:charmcraft\'\n* Command exit code: 1\n* Command standard error output: b\'Error: Failed creating project "charmcraft": Failed adding database record: This "projects" entry already exists\\n\'', resolution=None)
Full execution log: '/home/runner/.local/state/charmcraft/log/charmcraft-20230628-102516.095719.log'
```
here is an example run:
https://github.com/canonical/kfp-operators/actions/runs/5399918594/jobs/9807754324
### To Reproduce
I cannot reproduce it locally, but this is in our CI: https://github.com/canonical/kfp-operators/actions/runs/5399918594/jobs/9807754324
### Environment
lxd 5.15-3fe7435
Ubuntu 20.04
### charmcraft.yaml
```shell
# Learn more about charmcraft.yaml configuration at:
# https://juju.is/docs/sdk/charmcraft-config
type: "charm"
bases:
- build-on:
- name: "ubuntu"
channel: "20.04"
run-on:
- name: "ubuntu"
channel: "20.04"
parts:
charm:
charm-python-packages: [setuptools, pip] # Fixes install of some packages
```
### Relevant log output
```shell
-
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen3.6-35b-a3b-mtp-q6 | — | — | Fixed in charmcraft and craft-providers. Parallel LXD commands like lxc project create and lxc copy caused race conditions during simultaneous charm packing. Concurrency controls resolved the issue in charmcraft edge and candidate 2.4.0. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed as fixed. Maintainers resolved the LXD race condition causing parallel charm build failures in charmcraft and craft-providers. The fix was deployed to the edge channel, addressing project creation and instance busy operation errors. | |
| qwen/qwen3.6-35b-a3b | — | — | Fixed in craft-providers and charmcraft edge builds. The LXD race condition causing parallel charm packing failures was resolved by addressing database and instance creation conflicts. Maintainers verified the fix and closed the issue. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Resolved in charmcraft edge and candidate 2.4.0. Concurrency safeguards were implemented to prevent LXD race conditions during parallel charm packing, fixing both project creation and instance copy failures. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Fixed in code and released in charmcraft edge channel. Synchronizing LXD project and instance operations resolved the race condition during parallel charm packing, aligning with prior craft-providers fixes. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #391 LXD issue when build multiple charms in parallel | craft-providers | open | LXD race condition causing parallel charm build failures; reopened by maintainer after resurfacing in modern Charmcraft | |
| #554 Issues with concurrent builds | charmcraft | closed | Concurrent charm builds triggered LXD race conditions and project conflicts. A fix resolving these concurrency issues is now included in Charmcraft, closing the issue. |