Multi-base charm uses same LXC container for different bases
Metadata
Current evaluation
Closed in favor of upstream craft-application#600, which tracked platform-specific build-environment naming; builds were correct, but container reuse slowed iterative multi-base packs.
Resolution: closed superseded
Reason: Maintainer @mr-cal's 2025-01-06 comment identifies canonical/craft-application#600 as the upstream issue, following the craft-providers#544 investigation; no Charmcraft fixing PR or commit is recorded. The problem was an inefficient shared container name, not incorrect build isolation.
Evaluated by: mr-cal-bot
No scores available.
Issue body
### Bug Description
When packing a charm with
```yaml
platforms:
ubuntu@20.04:amd64:
ubuntu@22.04:amd64:
```
charmcraft uses the same LXC container for both platforms. This means that if you pack the 20.04 charm, then the 22.04 charm, and then the 20.04 charm, the 3rd pack will be slow because the container from the 1st pack was overriden
#### Expected behavior
charmcraft uses different LXC containers for each platform. (In aforementioned example) the 3rd pack is fast because it reuses the container from the 1st pack
### To Reproduce
```
git clone https://github.com/canonical/mysql-router-operator
cd mysql-router-operator
git checkout f12c6bb4b8b49f238bf9d1874f453fa8950b2cb8
charmcraft pack -v
lxc --project charmcraft ls
```
```
$ lxc --project charmcraft ls
+---------------------------------------------------------------+---------+------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+---------------------------------------------------------------+---------+------+------+-----------+-----------+
| base-instance-charmcraft-buildd-base-v7--20d64a5acd5c317c9c8d | STOPPED | | | CONTAINER | 0 |
+---------------------------------------------------------------+---------+------+------+-----------+-----------+
| base-instance-charmcraft-buildd-base-v7--910533fdd664bd2cdbe9 | STOPPED | | | CONTAINER | 0 |
+---------------------------------------------------------------+---------+------+------+-----------+-----------+
| charmcraft-mysql-router-on-amd64-for-amd64-2393879 | STOPPED | | | CONTAINER | 0 |
+---------------------------------------------------------------+---------+------+------+-----------+-----------+
```
### Environment
Ubuntu 22.04
```
$ snap list
Name Version Rev Tracking Publisher Notes
charmcraft 3.2.2.post133+g455880a4 5682 3.x/edge canonical✓ classic
core18 20240920 2846 latest/stable canonical✓ base
core20 20240911 2434 latest/stable canonical✓ base
core22 20241119 1722 latest/stable canonical✓ base
core24 20240920 609 latest/stable canonical✓ base
juju 3.6.1 29241 3/stable canonical✓ -
lxd 5.0.4-497fe1e 31333 5.0/stable/… canonical✓ -
microk8s v1.29.11 7435 1.29-strict/stable canonical✓ -
snapcraft 8.5.1 13181 latest/stable canonical✓ classic
snapd 2.66.1 23258 latest/stable canonical✓ snapd
```
### charmcraft.yaml
```yaml
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
type: charm
platforms:
ubuntu@20.04:amd64:
ubuntu@22.04:amd64:
ubuntu@22.04:arm64:
# Files implicitly created by charmcraft without a part:
# - dispatch (https://github.com/canonical/charmcraft/pull/1898)
# - manifest.yaml
# (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/services/package.py#L259)
# Files implicitly copied/"primed" by charmcraft without a part:
# - actions.yaml, config.yaml, metadata.yaml
# (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/services/package.py#L290-L293
# https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/services/package.py#L156-L157)
parts:
# "poetry-deps" part name is a magic constant
# https://github.com/canonical/craft-parts/pull/901
poetry-deps:
plugin: nil
build-packages:
- curl
override-build: |
python3 -m pip install --upgrade pip==24.3.1 # renovate: charmcraft-pip-latest
curl -sSL https://install.python-poetry.org | python3 - --version 1.8.4 # renovate: charmcraft-poetry-latest
ln -sf "$HOME/.local/bin/poetry" /usr/local/bin/poetry
# "charm-poetry" part name is arbitrary; use for consistency
# Avoid using "charm" part name since that has special meaning to charmcraft
charm-poetry:
# By default, the `poetry` plugin creates/primes these directories:
# - lib, src
# (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/parts/plugins/_poetry.py#L76-L78)
# - venv
# (https://github.com/canonical/charmcraft/blob/9ff19c328e23b50cc06f04e8a5ad4835740badf4/charmcraft/parts/plugins/_poetry.py#L95
# https://github.com/canonical/craft-parts/blob/afb0d652eb330b6aaad4f40fbd6e5357d358de47/craft_parts/plugins/base.py#L270)
plugin: poetry
source: .
after:
- poetry-deps
poetry-export-extra-args: ['--only', 'main,charm-libs']
build-snaps:
- rustup
build-packages:
- libffi-dev
- libssl-dev
- pkg-config
override-build: |
rustup default stable
craftctl default
# Include requirements.txt in *.charm artifact for easier debugging
cp requirements.txt "$CRAFT_PART_INSTALL/requirements.txt"
# "files" part name is arbitrary; use for consistency
files:
plugin: dump
source: .
build-packages:
- git
override-build: |
# Workaround to add unique identifier (git hash) to charm version while specification
# DA053 - Charm versioning
# (https://docs.google.com/document/d/1Jv1jhWLl8ejK3iJn7Q3VbCIM9GIhp8926bgXpdtx-Sg/edit?pli=1)
# is pending review.
python3 -c 'import pathlib; import shutil; import subprocess; git_hash=subprocess.run(["git", "describe", "--always", "--dirty"], capture_output=True, check=True, encoding="utf-8").stdout; file = pathlib.Path("charm_version"); shutil.copy(file, pathlib.Path("charm_version.backup")); version = file.read_text().strip(); file.write_text(f"{version}+{git_hash}")'
craftctl default
prime:
- LICENSE
- charm_version
- workload_version
- templates
```
### Relevant log output
```shell
Starting charmcraft, version 3.2.2.post133+g455880a4
Logging execution to '/home/ubuntu/.local/state/charmcraft/log/charmcraft-20241220-092903.384319.log'
Launching managed ubuntu 20.04 instance...
Creating new instance from remote
Creating new base instance from remote
Creating new instance from base instance
Starting instance
Starting charmcraft, version 3.2.2.post133+g455880a4
[...]
Packing...
Packing charm mysql-router_ubuntu@20.04:amd64.charm
Packed mysql-router_ubuntu@20.04:amd64.charm
Launching managed ubuntu 22.04 instance...
Starting instance
Creating instance from base instance
Starting instance
Starting charmcraft, version 3.2.2.post133+g455880a4
[...]
Packing...
Packing charm mysql-router_ubuntu@22.04:amd64.charm
Packed mysql-router_ubuntu@22.04:amd64.charm
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed superseded | Closed in favor of upstream craft-application#600, which tracked platform-specific build-environment naming; builds were correct, but container reuse slowed iterative multi-base packs. | |
| stealth/space-bunny-alpha | — | closed superseded | Closed as upstream work: platform-specific LXC naming moved to canonical/craft-application#600 and was implemented there in commit 5ae7f878. | |
| stealth/space-bunny-alpha | — | closed superseded | Container reuse was confirmed as a performance issue; platform-specific build-environment naming was moved upstream to canonical/craft-application#600. | |
| stealth/space-bunny-alpha | — | closed superseded | Reassigned to upstream canonical/craft-application#600 for platform-specific build-environment naming; no Charmcraft fix PR or commit was recorded. | |
| stealth/space-bunny-alpha | — | closed superseded | Closed as upstream work: platform-specific build-environment naming was tracked in canonical/craft-application#600; no public implementation or fixing PR was recorded. | |
| stealth/space-bunny-alpha | — | closed superseded | Deferred to craft-application#600; charmcraft reused one LXC name across bases, forcing unnecessary container recreation. No public fix was linked. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Superseded by upstream issue canonical/craft-application#600. The LXC container reuse bug causing rebuild slowdowns for multi-base charms is deferred to craft-application and craft-providers for resolution. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed and superseded by upstream issues in craft-providers and craft-application. Maintainers confirmed the container reuse causes unnecessary rebuilds and redirected resolution to craft-application#600. | |
| qwen/qwen3.6-35b-a3b | — | — | Superseded by upstream tracking in craft-application issue #600. Charmcraft incorrectly reuses LXC containers across different bases, causing slow rebuilds. The fix will be addressed in the upstream dependency. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Superseded by upstream issues in craft-providers and craft-application. The LXC container reuse bug causing slow rebuilds was tracked upstream, with resolution deferred to craft-application#600. |
Update history
No update history recorded yet.
Related work
-
Superseded By:
canonical/craft-application#600
(confidence 99%)
Maintainer linked this as the upstream tracking issue for platform-specific instance naming.
-
Related To:
canonical/craft-providers#544
(confidence 95%)
Maintainer identified #544 as the related provider-level container-name investigation.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1789 Unable to build multi-base subordinate charms on 24.04 | charmcraft | closed | Multi-base builds were implemented with platforms-based recipes in merged PR #2054 (commit 1ad02d82), enabling one recipe to build charms for multiple Ubuntu bases. |