← Back to issue list

Investigation: Spread test failures are due to craft_providers snapd initialization issue

View original Github issue

Metadata

Project
charmcraft
Number
#2509
Type
pull request
State
open
Author
Copilot
Labels
Created
Updated
Closed

Current evaluation

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.

Suggested action: close stale

Reason: The PR is a +200/-0 single-file documentation change with no maintainer review and no activity since 2025-12-08 (263 days). Its purpose is moot: the bug report was filed upstream as canonical/craft-providers#870, and craft-providers main now contains commit e0f6bc7 'fix: retry "snap watch" (#899)' which wraps snap_watch in retry.retry_until_timeout inside _disable_and_wait_for_snap_refresh — exactly the retry-with-backoff fix this PR recommended, so the in-repo bug report document is no longer applicable.

Impact: 10 Quick Win: 9.0 Staleness: 85 Complexity: 10 Confidence: 82

Issue body

This PR documents the investigation into spread test failures that show "daemon is stopping to wait for socket activation" and "Failed to wait for snap refreshes to complete" errors in smoketests/reactive and smoketests/different-dir. ## Investigation Results The failures occur **inside** LXD containers created by the craft_providers library during charm builds, not on the host system where spread tests run. The error happens when craft_providers sets up base LXD containers and runs `snap watch --last=auto-refresh?` inside those containers while snapd is in a transitional state. ## Root Cause The issue is in the craft_providers library's container initialization code (specifically in `craft_providers/base.py` in the `_disable_and_wait_for_snap_refresh` method around line 616). The spread.yaml prepare sections only configure the host system (Google Cloud instances) and cannot affect the internal setup of LXD containers created by charmcraft during builds. ## Bug Report for craft-providers A comprehensive bug report has been prepared and documented in `craft-providers-bug-report.md` that should be filed at: https://github.com/canonical/craft-providers/issues The report includes: - Complete error details and stack traces from the failing builds - Root cause analysis of the snapd transitional state issue - Three proposed solutions with detailed code examples: 1. Retry logic with exponential backoff (recommended) 2. Enhanced snapd readiness checks before snap operations 3. Graceful degradation with warnings - Impact assessment on charmcraft and other craft-providers consumers - Steps to reproduce the issue ### Recommended Fix The bug report recommends implementing retry logic with exponential backoff in the `_disable_and_wait_for_snap_refresh` method to handle the transient "daemon is stopping to wait for socket activation" error gracefully. This approach would allow the container initialization to succeed even when snapd is temporarily in a transitional state. The fix needs to be made in the craft_providers library, as this is outside the scope of what can be fixed through spread.yaml modifications in the charmcraft repository. --- - [ ] I've followed the [contribution guidelines](https://github.com/canonical/charmcraft/blob/main/CONTRIBUTING.md). - [ ] I've signed the [CLA](http://www.ubuntu.com/legal/contributors/). - [ ] I've successfully run `make lint && make test`. - [ ] I've added or updated any relevant documentation. - [ ] I've updated the relevant release notes. <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > # Fix Spread Test Job Failure: LXD Snap Refresh > > Recent workflow runs ([see logs](https://github.com/canonical/charmcraft/actions/runs/19978096550/job/57299831626)) show that spread tests are failing due to errors like: > > ``` > error: daemon is stopping to wait for socket activation > craft_providers.lxd.errors.LXDError: Failed to wait for snap refreshes to complete. > ``` > This problem occurs during container setup when waiting for snapd refreshes in LXD containers, causing build/test failures in jobs such as `smoketests/reactive:stable` and `smoketests/different-dir`. > > ## Solution > Modify the setup steps in `.github/workflows/spread.yaml` to ensure snapd is running and healthy before spread/charmcraft commands are executed in the test container. This can be done by adding commands to restart snapd and wait for its readiness inside the container. > > ### Example fix (snippet): > Add before running charmcraft/spread tests: > ```yaml > - name: Ensure snapd is running in the LXD container > run: | > lxc exec <container-name> -- systemctl restart snapd > lxc exec <container-name> -- snap wait system seed.loaded > ``` > Replace `<container-name>` with the actual name of the LXD instance used in the workflow setup. > > ### Screenshots/logs referenced for failure > Refer to the job log for the full error trace and explanation: https://github.com/canonical/charmcraft/actions/runs/19978096550/job/57299831626 > > # Images > None attached. > </details> <!-- START COPILOT CODING AGENT SUFFIX --> *This pull request was created as a result of the following prompt from Copilot chat.* > # Fix Spread Test Job Failure: LXD Snap Refresh > > Recent workflow runs ([see logs](https://github.com/canonical/charmcraft/actions/runs/19978096550/job/57299831626)) show that spread tests are failing due to errors like: > > ``` > error: daemon is stopping to wait for socket activation > craft_providers.lxd.errors.LXDError: Failed to wait for snap refreshes to complete. > ``` > This problem occurs during container setup when waiting for snapd refreshes in LXD containers, causing build/test failures in jobs such as `smoketests/reactive:stable` and `smoketests/different-dir`. > > ## Solution > Modify the setup steps in `.github/workflows/spread.yaml` to ensure snapd is running and healthy before spread/charmcraft commands are executed in the test container. This can be done by adding commands to restart snapd and wait for its readiness inside the container. > > ### Example fix (snippet): > Add before running charmcraft/spread tests: > ```yaml > - name: Ensure snapd is running in the LXD container > run: | > lxc exec <container-name> -- systemctl restart snapd > lxc exec <container-name> -- snap wait system seed.loaded > ``` > Replace `<container-name>` with the actual name of the LXD instance used in the workflow setup. > > ### Screenshots/logs referenced for failure > Refer to the job log for the full error trace and explanation: https://github.com/canonical/charmcraft/actions/runs/19978096550/job/57299831626 > > # Images > None attached. > <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 10
Quick Win: 9.0
Staleness: 85
Complexity: 10
Confidence: 82
close stale 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.
qwen/qwen3.6-35b-a3b
Staleness: 90
Complexity: 15
Confidence: 90
close stale Investigation documentation for spread test failures pointing to craft-providers. Adds a bug report markdown file. Currently inactive and pending external resolution.
qwen3.6-35b-a3b-mtp-q6
Staleness: 90
Complexity: 10
Confidence: 90
close stale Documents investigation into spread test failures caused by craft_providers snapd initialization. Adds a bug report markdown file. Currently inactive for 7 months.
qwen3.6-35b-a3b-mtp-q6
Staleness: 95
Complexity: 10
Confidence: 95
close stale Documents investigation into spread test failures caused by craft_providers snapd initialization. Maintainer confirmed the proposed fix was ineffective and redirected the issue to an upstream bug report. PR is inactive and irrelevant to this repository.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 5
Confidence: 95
close stale Investigation into spread test failures caused by snapd initialization errors in craft_providers LXD containers. Root cause identified upstream; bug report drafted with recommended retry logic. Awaiting upstream triage and assignment.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/craft-providers#899 (confidence 85%)

    Commit e0f6bc7 'fix: retry snap watch (#899)' adds retry_until_timeout around snap_watch in _disable_and_wait_for_snap_refresh, the exact fix this PR's bug report recommended for the 'daemon is stopping to wait for socket activation' error.

  • Related To: canonical/craft-providers#870 (confidence 80%)

    Upstream issue matching this PR's investigation: snapd socket-activation race during LXD container initialization, with the same recommended retry-based fix; the PR's bug report was filed there per @lengau's request.

Related issues

Issue Project State Summary Similarity
#3962 Setup snapd for snapcraft_legacy providers snapcraft merged 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.
76%
#2020691 Snapcraft spread tests should be tested with every provider snapcraft (launchpad) closed Spread tests run inconsistently across LXD and Multipass providers due to differing base image contents. Suggests running tests on all providers to ensure compatibility. Currently untriaged and inactive for nearly 3 years.
75%
#806 Use `snapcraft test` for spread tests craft-application open Dogfooding task to switch craft-application CI from running spread directly to using snapcraft test. Triaged; open PR #1038 stalled ~165 days with failing CI; workflow still runs spread directly at HEAD.
71%