lxd: merge existing image info contents
Metadata
Current evaluation
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.
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 implements support for merging the contents of `SNAPCRAFT_IMAGE_INFO` set when building in a container with the information gathered from LXD in the container. The result of it will go into `manifest.yaml` if `SNAPCRAFT_BUILD_INFO` is set (as usual). The exact values aren't filtered but taken as-is - InvalidLaunchpadBuildInfoError is raised if the parsing fails.
This variable is going to be set by [buildd](https://launchpad.net/launchpad-buildd).
Note on compatibility: Older Snapcraft versions already pick up `SNAPCRAFT_IMAGE_INFO`, the main take away here is that builds in containers will merge the provided JSON with what's taken from the container.
The following new tests are being added:
- tests.unit.test_lifecycle.RecordManifestTestCase.test_prime_with_launchpad_build_info_records_manifest
- tests.unit.test_lxd.ContainerbuildTestCase.test_image_info_merged
- To verify the contents of SNAPCRAFT_IMAGE_INFO will be merged with the values populated from the LXD container.
- tests.unit.test_lxd.ContainerbuildTestCase.test_image_info_invalid
- To verify that invalid JSON raises an error.
- tests.unit.test_lxd.test_launchpad_build_info_set
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_IMAGE_INFO='{"build_url":"test-build-url"}' SNAPCRAFT_BUILD_INFO=1 snapcraft
- grep -C 1 build_url prime/snap/manifest.yaml
image-info:
build_url: test-build-url
build-packages: []
- Observe the manifest containing build-info with build-url.
- snapcraft clean
- SNAPCRAFT_IMAGE_INFO=not-json SNAPCRAFT_BUILD_INFO=1 snapcraft
- Observe the error message "Failed to parse container image info: SNAPCRAFT_IMAGE_INFO is not a valid JSON string: not-json".
- snapcraft clean
- SNAPCRAFT_CONTAINER_BUILDS=1 SNAPCRAFT_IMAGE_INFO='{"build_url":"test-build-url"}' SNAPCRAFT_BUILD_INFO=1 snapcraft
- grep -C 1 build_url prime/snap/manifest.yaml
architecture: x86_64
build_url: test-build-url
created_at: '2018-03-23T00:00:00Z'
- Note: The architecture may be wrong because of [LP: #1760857](https://bugs.launchpad.net/snapcraft/+bug/1760857).
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | 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. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged implementation to merge SNAPCRAFT_IMAGE_INFO with LXD container data for manifest.yaml. Conflicts were resolved, and an unrelated architecture detection regression was tracked as LP:1760857. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged implementation that combines SNAPCRAFT_IMAGE_INFO with LXD container data into manifest.yaml. Merge conflicts were resolved, and an unrelated architecture detection regression was documented during review. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1364 lxd: Inject snapcraft and core snaps into the container | snapcraft | merged | Merged. Injects the host's snapcraft and core snaps into LXD containers to ensure build version consistency. Approved by one reviewer, modifying nine files with 360 additions and 46 deletions. | |
| #2046 lxd: specify arch in lxc image list command | snapcraft | merged | 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. | |
| #1263 lxd: pass through commands into the container | snapcraft | merged | Merged a pull request enabling snapcraft to pass build commands into LXD containers. The change allows remote builds to execute within the container environment, addressing path mounting issues during remote snap creation. Approved by one reviewer, though coverage decreased slightly. | |
| #1633 recording: record information from the image in container builds | snapcraft | merged | Merged after reviewer feedback on LXD parsing. Records container image metadata during builds using json output with a fallback warning for older LXD versions, replacing an initial YAML approach. Updated 7 files. | |
| #1585 lxd: pass SNAPCRAFT_PARTS_URI through into container | snapcraft | merged | Merged to resolve bug 1719951. The change passes the SNAPCRAFT_PARTS_URI environment variable into LXD containers. Approved by one reviewer, passed CI checks, and added 19 lines across two files. | |
| #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. |