Hey there,
Somewhat frequently I’m observing simple errors in snapcraft bubbling up as a large traceback that makes it taste like an ugly crash, when it’s really just a minor annoyance.
For example, when removing and reinstalling a lxd from the ground up, I got this:
$ snapcraft cleanbuild
Creating snapcraft-gladly-vital-filly
error: Failed container creation:
- https://cloud-images.ubuntu.com/releases: No storage pool found. Please create a new storage pool.
Traceback (most recent call last):
File "/usr/bin/snapcraft", line 9, in <module>
load_entry_point('snapcraft==2.35', 'console_scripts', 'snapcraft')()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 542, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2569, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2229, in load
return self.resolve()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2235, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python3/dist-packages/snapcraft/cli/__main__.py", line 19, in <module>
run(prog_name='snapcraft')
File "/usr/lib/python3/dist-packages/click/core.py", line 716, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3/dist-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py", line 219, in cleanbuild
lifecycle.cleanbuild(project_options, remote)
File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_containers.py", line 66, in cleanbuild
metadata=config.get_metadata(), remote=remote).execute()
File "/usr/lib/python3/dist-packages/snapcraft/internal/lxd/_containerbuild.py", line 178, in execute
with self._container_running():
File "/usr/lib/python3.5/contextlib.py", line 59, in __enter__
return next(self.gen)
File "/usr/lib/python3/dist-packages/snapcraft/internal/lxd/_containerbuild.py", line 95, in _container_running
with self._ensure_started():
File "/usr/lib/python3.5/contextlib.py", line 59, in __enter__
return next(self.gen)
File "/usr/lib/python3/dist-packages/snapcraft/internal/lxd/_containerbuild.py", line 112, in _ensure_started
self._ensure_container()
File "/usr/lib/python3/dist-packages/snapcraft/internal/lxd/_cleanbuilder.py", line 39, in _ensure_container
'lxc', 'launch', '-e', self._image, self._container_name])
File "/usr/lib/python3.5/subprocess.py", line 581, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['lxc', 'launch', '-e', 'ubuntu:xenial/amd64', 'local:snapcraft-gladly-vital-filly']' returned non-zero exit status 1
That’s a pretty straightforward error. All I needed was the three clean lines from lxc at the top to tell what to do. All the rest is eye-opening noise. And that’s just one example. I see other similar crashes relatively frequently.
Might be worthwhile to drive into the error handling logic, and try to make it more precise about when to display a fat panic, versus a nice little error message.