← 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
closed
Author
Copilot
Labels
—
Created
Updated
Closed

Current evaluation

Investigation-only PR #2509 (added craft-providers-bug-report.md) closed unmerged. Diagnosis was correct; fix landed upstream in craft-providers PR #899 (commit e0f6bc7, retry `snap watch`), reaching charmcraft via #2583 in 4.2.0.

Resolution: closed superseded

Reason: The PR was closed without merging after lengau redirected the work upstream: 'open a descriptive bug report in craft-providers'. That was done (craft-providers#870, from #898) and fixed by merged craft-providers PR #899 (commit e0f6bc7, 'fix: retry snap watch'), released in craft-providers 3.3.0 and pulled into charmcraft by merged dependency-update PR #2583 (charmcraft 4.2.0), tracking issue charmcraft#2515.

Evaluated by: mr-cal-bot

No scores available.

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
stealth/space-bunny-alpha — closed superseded Investigation-only PR #2509 (added craft-providers-bug-report.md) closed unmerged. Diagnosis was correct; fix landed upstream in craft-providers PR #899 (commit e0f6bc7, retry `snap watch`), reaching charmcraft via #2583 in 4.2.0.
stealth/space-bunny-alpha — closed superseded Documentation-only PR #2509 was closed unmerged; its diagnosis was addressed upstream by merged craft-providers PR #899 (e0f6bc7), released in 3.3.0.
qwen/qwen3.6-35b-a3b
Impact: 5
Quick Win: 0
Complexity: 5
Confidence: 90
Actionability: 10
close superseded 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.8-27b
Impact: 10
Quick Win: 9
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.

Update history

Date Change
closed

Related work

  • Superseded By: craft-providers#899 (confidence 96%)

    Merged upstream fix retrying `snap watch` in craft_providers LXD init, the exact fix #2509 proposed; released in craft-providers 3.3.0

  • Related To: craft-providers#870 (confidence 90%)

    Upstream craft-providers bug report for the 'daemon is stopping to wait for socket activation' LXD init failure, filed per lengau's request on #2509

  • Duplicate Of: craft-providers#898 (confidence 82%)

    Same intermittent snapd socket timeout issue upstream, closed by PR #899

  • Likely Fixed By: canonical/charmcraft#2583 (confidence 78%)

    Merged bulk dependency update (e66a25b5) that pulled in the craft-providers fix for Charmcraft 4.2.0

  • Related To: canonical/charmcraft#2515 (confidence 74%)

    Follow-up charmcraft issue for the same flaky spread failure, closed once #2583 landed the craft-providers fix

Related issues

Issue Project State Summary Similarity
#1098 build: update craft-providers rockcraft merged Merged craft-providers update in #1098 (commit bef64dc8) to address recurring snapd watch errors in spread tests.
75%
#2516 fix: disable reactive:stable test variant due to snapd timing issue in craft-providers charmcraft closed Closed unmerged: the test-disable workaround was superseded by Charmcraft 4.2.0’s craft-providers 3.3.0 update, which retries the transient snapd failure.
74%
#2515 `google:ubuntu-20.04-64:tests/spread/smoketests/reactive:stable` spread test is failing charmcraft closed Flaky LXD error 'Failed to wait for snap refreshes to complete' (snapd race SNAPDENG-36387) traced to craft-providers; fixed by retrying `snap watch` in craft-providers PR #899, pulled in by charmcraft PR #2583 and released in charmcraft 4.2.0.
71%
#1295 Parallel build test is flaky charmcraft closed Flakiness in the parallel-build spread test traced to a craft-providers instance race; closed after charmcraft PR #1294 (commit 59b70f01) upgraded craft-providers to v1.18.0, per @syu-w's comment.
70%