lxd: specify arch in lxc image list command
Metadata
Current evaluation
Merged fix for LXD image listing regression. Explicitly specifies architecture in the lxc image list command to ensure correct SNAPCRAFT_IMAGE_INFO values in the manifest. Resolves LP: #1760857. Tests updated.
Suggested action: —
No scores available.
Issue body
- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [x] If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on [bug reports](https://bugs.launchpad.net/snapcraft)?
- [x] If this is a new feature. Have you discussed the design on the [forum](https://forum.snapcraft.io)?
- [x] Have you successfully run `./runtests.sh static`?
- [x] Have you successfully run `./runtests.sh unit`?
-----
This PR fixes getting the correct values for the LXD image for `SNAPCRAFT_IMAGE_INFO` (which is added to the manifest if `SNAPCRAFT_BUILD_INFO` is set). This regressed when the image used to create containers stopped containing the architecture as `ubuntu:xenial` rather than `ubuntu:xenial/$ARCH`, which is still passed to `lxc image list`. So in the end we got all matching images in an unordered list. The fix is to specify the architecture explicitly.
Fixes: [LP: #1760857](https://bugs.launchpad.net/snapcraft/+bug/1760857)
The following new tests are being modified:
- tests.unit.test_lxd.CleanbuilderTestCase.test_cleanbuild
- To verify that the image info is obtained for the right architecture.
- tests.unit.test_lxd.FailedImageInfoTestCase.test_failed_image_info_just_warns
- To verify the exact command appearing in the error message.
I locally ran the tests:
- `./runtests.sh tests/unit` unrelated failures in [tests.unit.test_lifecycle.CoreSetupTestCase.test_core_setup_if_docker_env](https://bugs.launchpad.net/snapcraft/+bug/1752576) and `tests.unit.test_elf`.
- `./runtests.sh tests/integration` with one unrelated failure in [tests.integration.general.test_parser.TestParserWikis](https://bugs.launchpad.net/snapcraft/+bug/1752580).
- `./runtests.sh tests/static`: Everything passed
Manual test steps:
- Build and install a Snapcraft snap from this branch.
- cd tests/integration/snaps/basic
- SNAPCRAFT_BUILD_INFO=1 snapcraft cleanbuild
- Open prime/snap/manifest.yaml from the resulting snap.
- Observe the manifest containing the right architecture.
- Repeat this step a few times to ensure the value is the same.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Merged fix for LXD image listing regression. Explicitly specifies architecture in the lxc image list command to ensure correct SNAPCRAFT_IMAGE_INFO values in the manifest. Resolves LP: #1760857. Tests updated. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged a fix for the LXD builder that explicitly specifies the architecture in the lxc image list command. This resolves a regression causing unordered or incorrect SNAPCRAFT_IMAGE_INFO values in the manifest, addressing LP: #1760857. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged fix resolving an LXD image listing regression by explicitly specifying architecture in the lxc image list command. This ensures accurate SNAPCRAFT_IMAGE_INFO in manifests, resolves LP: #1760857, and includes updated unit tests for architecture-specific verification. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1718 lxd: let lxd choose the architecture | snapcraft | merged | Merged after two approvals and passing CI. Removes snapcraft's redundant LXD architecture selection logic, delegating it to LXD. Architecture recording now occurs post-container startup. Released with version 2.35. | |
| #1577 lxd: don't inject local snaps on a different arch | snapcraft | merged | Merged a fix preventing Snapcraft from injecting local snaps into LXD containers with mismatched architectures. Cross-arch remotes now install snaps from the store. Approved by reviewers and merged after CI checks. | |
| #1997 lxd: merge existing image info contents | snapcraft | merged | Merged. The change adds functionality to combine SNAPCRAFT_IMAGE_INFO with LXD container metadata in manifest.yaml. Review identified a separate architecture detection bug, tracked as LP: #1760857, which was resolved independently. | |
| #1760857 SNAPCRAFT_IMAGE_INFO contains wrong architecture | snapcraft (launchpad) | closed | Closed without a linked fix or comments, indicating abandonment. The bug stems from lxc image list returning multiple matches, causing incorrect architecture values in SNAPCRAFT_IMAGE_INFO. |