← Back to issue list

lxd: friendly errror with suggestions if network is broken

View original Github issue

Metadata

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

Current evaluation

Merged improvements to LXD network error handling replace raw stack traces with user-friendly messages and troubleshooting hints. The update explicitly catches connection and encoding exceptions, updates tests, and resolves Launchpad bug #1719952.

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`? ----- As evidenced by [LP: #1749679](https://bugs.launchpad.net/snapcraft/+bug/1749679) the verbatim network probing failures aren't very helpful. We can try to reduce noise and give some hints as to what's wrong. `ContainerConnectionError` will ensure there's a link to LXD docs and the URL we check is mentioned in the message. `urllib.error.URLError` is handled explicitly to get a niceish error message in the case of connection errors. All other exceptions will generically be caught as well since we don't want a stack trace in any event and **urllib** can leak other exceptions such as `UnicodeError`. Fixes: [LP: #1719952](https://bugs.launchpad.net/snapcraft/+bug/1719952) The following tests were updated: - tests.unit.commands.test_snap - tests.unit.test_lxd 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 test steps: - cd tests/integration/snaps/basic - snapcraft cleanbuild - lxc profile set default environment.http_proxy localhost:1234 - Observe `Failed to open 'http://start.ubuntu.com/connectivity-check.html': [Errno 111] Connection refused` - lxc profile set default environment.http_proxy invalid - Observe `Failed to open 'http://start.ubuntu.com/connectivity-check.html': [Errno -2] Name or service not known` - lxc profile set default environment.http_proxy http://unknown - Observe `Failed to open 'http://start.ubuntu.com/connectivity-check.html': [Errno -2] Name or service not known` - lxc profile set default environment.http_proxy .invalid - Observe `Failed to open 'http://start.ubuntu.com/connectivity-check.html': encoding with 'idna' codec failed (UnicodeError: label empty or too long)` Note: Use `lxc profile set default environment.http_proxy ''` to unset the proxy in the default LXD profile after testing, or set it to the value you were using previously.

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b Merged improvements to LXD network error handling replace raw stack traces with user-friendly messages and troubleshooting hints. The update explicitly catches connection and encoding exceptions, updates tests, and resolves Launchpad bug #1719952.
qwen3.6-35b-a3b-mtp-q6 Merged. Replaces raw LXD network traces with user-friendly error messages and hints. Handles urllib and container exceptions to prevent stack traces, updates tests, and resolves LP: #1719952.
qwen3.6-35b-a3b-mtp-q6 Merged by kalikiana to improve LXD network error handling. The change catches ContainerConnectionError and urllib.error.URLError, replacing raw stack traces with user-friendly messages and troubleshooting hints, resolving LP: #1719952.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#2095 lxd: proper error classes for container errors snapcraft merged Merged after approval. Refactored LXD container errors into dedicated classes, relocated them to the LXD module, and fixed architecture retrieval error handling. Added corresponding unit tests. Resolves Launchpad bugs #1734233 and #1734235.
72%
#1647 lxd: better surfacing of errors snapcraft merged Merged. Resolves duplicate error printing in LXD by having callers return silent errors with proper exit codes, allowing callees to handle message display. Approved and merged after CI validation.
70%