← Back to issue list

Setup snapd for snapcraft_legacy providers

View original Github issue

Metadata

Project
snapcraft
Number
#3962
Type
pull request
State
merged
Author
mr-cal
Labels
Created
Updated
Closed

Current evaluation

Merged a fix for failing spread tests caused by missing snapd sockets in LXD containers. The change adopts snapd initialization logic from craft-providers to properly start the service, resolving connection errors. Approved and passed CI.

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] Have you successfully run `make lint`? - [X] Have you successfully run `pytest tests/unit`? ----- ## Issue A spread test on core18 started [consistently failing](https://github.com/snapcore/snapcraft/actions/runs/3329677836/jobs/5510607616) today. The error is: ``` + sudo -iu ubuntu env -i PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin bash -c 'cd /snapcraft/tests/spread/plugins/v2/snaps/make-hello && snapcraft try --use-lxd' Launching a container. Waiting for container to be ready Waiting for network to be ready... error: cannot communicate with server: Put http://localhost/v2/snaps/system/conf: dial unix /run/snapd.socket: connect: no such file or directory Starting Snapcraft 7.2.1.post6+git822e6686 Logging execution to '/home/ubuntu/.cache/snapcraft/log/snapcraft-20221026-173239.952534.log' An error occurred when trying to execute 'snap unset system proxy.http' with 'LXD': returned exit code 1. ``` I'm not sure why the snapd socket isn't open. I wonder if it's due to an update to snapd. Snapcraft_legacy injects a copy of snapd from the host into the container. It's currently injecting snapd v`2.57.5`. I'm not sure why it's failing only on this particular spread test that calls `snapcraft try`. ## Solution I copied the [snapd setup code](https://github.com/canonical/craft-providers/blob/ab325f27215ae669e6a9f41c507fa79a28f33b19/craft_providers/bases/buildd.py#L695) from `craft-providers`, which appears to solve the problem. (Although a `sleep()` function fixes the error too, the `craft-providers` code is a safer solution)

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b Merged a fix for failing spread tests caused by missing snapd sockets in LXD containers. The change adopts snapd initialization logic from craft-providers to properly start the service, resolving connection errors. Approved and passed CI.
qwen3.6-35b-a3b-mtp-q6 Merged a fix for failing core18 spread tests by initializing snapd in LXD containers for snapcraft_legacy providers. Adopted snapd setup logic from craft-providers to resolve socket connection errors.
qwen3.6-35b-a3b-mtp-q6 Merged to resolve a core18 spread test failure caused by a missing snapd socket in LXD containers. Adopted snapd initialization logic from craft-providers to properly configure snapcraft_legacy providers.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#2647 build providers: catch LXD socket error snapcraft merged Merged to catch LXD socket errors in build providers, resolving SNAPCRAFT-WA. Approved by reviewer, passed CI checks, and integrated with a 14-line addition and 6-line deletion across three files. Minor test coverage decrease noted but did not block merge.
77%
#2509 build providers: initial support for LXD snapcraft merged Merged initial LXD build provider support for snapcraft, enabling the --use-lxd flag for lifecycle steps and cleaning. Passes CI. Reviewers noted minor dependency and container setup edge cases, which were clarified or deferred.
77%
#2509 Investigation: Spread test failures are due to craft_providers snapd initialization issue charmcraft open Documentation-only PR adding craft-providers-bug-report.md about spread test failures from a snapd socket-activation race in LXD containers. Inactive ~8.5 months; the recommended retry fix was merged upstream in craft-providers.
76%
#1098 build: update craft-providers rockcraft merged Merged update to the craft-providers dependency to resolve recurring snapd watch errors in spread tests. Approved by two reviewers and passed CI checks. The change modifies three files with minor adjustments.
74%
#4638 fix(application): use SNAPCRAFT_MANAGED_MODE everywhere snapcraft merged Merged. Replaces CRAFT_MANAGED_MODE with SNAPCRAFT_MANAGED_MODE to fix log loss in nested LXD instances. Approved by two reviewers and passed CI. Does not address unrelated spread test failures.
73%
#2937 spread tests: do not attempt to remove snapd snap snapcraft merged Merged a one-line fix to prevent spread tests from removing the snapd snap in LXD environments, resolving test failures caused by snapd's protected status. Approved by one reviewer with passing CI checks.
73%
#4032 requirements: update craft-providers to 1.7.2 snapcraft merged Merged dependency update to craft-providers 1.7.2. Resolves LXD instance ID map checking for core22 snaps, preventing dubious ownership errors when multiple users launch the same instance. Approved and passed CI.
72%
#473 snap: add configure hook with support for provider (CRAFT-363) charmcraft merged Merged. Added a snap configure hook to validate the provider setting, restricting it to multipass or lxd. Updated requirements to include snap-helpers. Validation errors on invalid values but is reserved for future use. Approved by two reviewers.
72%
#3725 tests: use lxd in clean provider test snapcraft merged Merged into snapcraft/7.0. Enables LXD in provider cleaning tests to align with destructive mode testing. Approved by one reviewer, passed CI checks, and maintained existing code coverage.
72%
#2222 lxd: support new style snap injection snapcraft merged Merged after implementing new style snap injection for LXD. Refactored provider logic, normalized code, and removed test duplication. Approved by two reviewers, passed CI, and verified via edge channel testing.
72%