← Back to issue list

lxd: wait for on-going refreshes to finish

View original Github issue

Metadata

Project
snapcraft
Number
#2098
Type
pull request
State
merged
Author
kalikiana
Labels
—
Created
Updated
Closed

Current evaluation

PR #2098 by kalikiana merged (commit 7666a74a7), adding a `snap watch` call before injecting core/snapcraft snaps into LXD containers so in-progress refreshes finish. Fixes #2037 and LP bug #1722049.

Resolution: closed resolved

Reason: The PR was merged into snapcraft as commit 7666a74a7 ("lxd: wait for on-going refreshes to finish (#2098)"), adding the wait-for-refreshes logic and updating tests.unit.test_lxd.test_inject_snap. It fixes the race where a concurrent `snap refresh core` inside an LXD container broke container builds, closing issue #2037.

Evaluated by: mr-cal-bot

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 adds a `snap watch` call before injecting (core and snapcraft) snaps into the LXD container to force any on-going refreshes to be done. Fixes: #2037 Fixes: [LP: #1722049](https://bugs.launchpad.net/snapcraft/+bug/1722049) The following tests were updated: - tests.unit.test_lxd.test_inject_snap - To verify that the `snap watch` call is made first. I locally ran the tests: - `./runtests.sh tests/unit` with unrelated failures in [tests.unit.test_lifecycle.CoreSetupTestCase.test_core_setup_if_docker_env](https://bugs.launchpad.net/snapcraft/+bug/1752576), `tests.unit.test_mangling.TestClearExecstack.test_execstack_clears` 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 static`: Everything passed Manual testing: - Testing this is a bit tricky because by design it's a race. First prepare a new container *running Snapcraft as a snap from this branch*. - SNAPCRAFT_CONTAINER_BUILDS=1 snapcraft pull - Run the following commands in tandem repeatedly to see that it won't cause a problem. Pick different channels for CHANNEL below eg. `--edge` or `--beta` to alternate so that refreshes won't be no-ops. Running this twice will confirm that there are indeed changes in progress, making Snapcraft fail without the fix. - lxc start snapcraft-basic - lxc exec snapcraft-basic -- snap refresh core --edge --no-wait - lxc exec snapcraft-basic -- snap refresh core --edge --no-wait - SNAPCRAFT_CONTAINER_BUILDS=1 snapcraft pull

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved PR #2098 by kalikiana merged (commit 7666a74a7), adding a `snap watch` call before injecting core/snapcraft snaps into LXD containers so in-progress refreshes finish. Fixes #2037 and LP bug #1722049.
stealth/space-bunny-alpha — closed resolved Merged PR #2098 in commit 7666a74a7, adding snap watch before snap injection into LXD containers to wait for ongoing refreshes and fix #2037.
qwen/qwen3.6-35b-a3b — — Merged fix adding a snap watch call before injecting snaps into LXD containers to wait for ongoing refreshes. Resolves race conditions causing build failures in issues #2037 and LP: #1722049. Approved by reviewer and passed CI.
qwen3.6-35b-a3b-mtp-q6 — — Merged a fix that adds a snap watch call to wait for ongoing refreshes before injecting core and snapcraft snaps into LXD containers, resolving race conditions in issues #2037 and LP: #1722049.

Update history

No update history recorded yet.

Related work

  • Related To: snapcraft#2037 (confidence 95%)

    Issue 'core refresh in container build breaks build' explicitly listed as fixed by this PR and is now closed.

Related issues

Issue Project State Summary Similarity
#1412 lxd: snapcraft refresh in containers snapcraft merged Merged PR #1412 as 3d511c5eb, making LXD container refresh install Snapcraft once while allowing packages and snaps to be updated in reusable containers.
75%
#1190 test(spread): wait for pending snap auto-refresh before refreshing lxd craft-application closed Superseded by merged PR canonical/craft-application#1170 (fea3e835), which added a broader snap auto-refresh hold and wait; #1190's narrower fix was closed unmerged.
75%
#1722049 core refresh in container build breaks build snapcraft (launchpad) closed Fixed by merged PR canonical/snapcraft#2098 (commit 7666a74a7), which waits for active snap refreshes before injecting build snaps into reusable LXD containers.
74%
#1739 lxd: refresh remote container snapcraft merged Merged #1739 as 2f9265f23, fixing snapcraft refresh to honor the LXD remote named by SNAPCRAFT_CONTAINER_BUILDS instead of using a local container.
74%
#1865 lxd: always (re-)injects snaps snapcraft merged Merged PR #1865 as e99354492, fixing LP #1741752 by ensuring LXD re-injects required snaps when needed.
71%
#1364 lxd: Inject snapcraft and core snaps into the container snapcraft merged Merged PR #1364 as 99f5598ac, injecting the host's Snapcraft and core snaps into LXD containers so builds no longer use a mismatched Xenial archive version.
71%