Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch FileNotFound for all subprocess.run() calls #584

Open
mr-cal opened this issue Jun 20, 2024 · 1 comment
Open

Catch FileNotFound for all subprocess.run() calls #584

mr-cal opened this issue Jun 20, 2024 · 1 comment
Labels
Enhancement New feature or request triaged We will be doing this

Comments

@mr-cal
Copy link
Collaborator

mr-cal commented Jun 20, 2024

What needs to get done

Catch FileNotFound for all subprocess.run() calls and raise a ProviderError.

Why it needs to get done

If the executable is not available, FileNotFound bubbles up as an internal error via craft-application.

Example

(testcraft_venv) root@u2204-parts-dev:/opt/testcraft/examples/ruff# testcraft pack
testcraft internal error: FileNotFoundError(2, 'No such file or directory')
Full execution log: '/root/.local/state/testcraft/log/testcraft-20240620-161753.039218.log'
2024-06-20 16:17:53.076 Executing on host: lxc remote list --format=yaml
2024-06-20 16:17:53.077 testcraft internal error: FileNotFoundError(2, 'No such file or directory')
2024-06-20 16:17:53.080 Traceback (most recent call last):
2024-06-20 16:17:53.080   File .../craft_application/application.py", line 536, in run
2024-06-20 16:17:53.080     self.run_managed(platform, build_for)
2024-06-20 16:17:53.080   File .../craft_application/application.py", line 361, in run_managed
2024-06-20 16:17:53.080     with self.services.provider.instance(
2024-06-20 16:17:53.080   File "/usr/lib/python3.10/contextlib.py", line 135, in __enter__
2024-06-20 16:17:53.080     return next(self.gen)
2024-06-20 16:17:53.080   File .../craft_application/services/provider.py", line 120, in instance
2024-06-20 16:17:53.080     with provider.launched_environment(
2024-06-20 16:17:53.080   File "/usr/lib/python3.10/contextlib.py", line 135, in __enter__
2024-06-20 16:17:53.080     return next(self.gen)
2024-06-20 16:17:53.080   File "/root/testcraft_venv/lib/python3.10/site-packages/craft_providers/lxd/lxd_provider.py", line 137, in launched_environment
2024-06-20 16:17:53.080     image.add_remote(lxc=self.lxc)
2024-06-20 16:17:53.080   File "/root/testcraft_venv/lib/python3.10/site-packages/craft_providers/lxd/remotes.py", line 97, in add_remote
2024-06-20 16:17:53.080     if self.remote_name in lxc.remote_list():
2024-06-20 16:17:53.080   File "/root/testcraft_venv/lib/python3.10/site-packages/craft_providers/lxd/lxc.py", line 1001, in remote_list
2024-06-20 16:17:53.080     proc = self._run_lxc(command, capture_output=True)
2024-06-20 16:17:53.080   File "/root/testcraft_venv/lib/python3.10/site-packages/craft_providers/lxd/lxc.py", line 104, in _run_lxc
2024-06-20 16:17:53.080     return subprocess.run(lxc_cmd, check=check, stdin=stdin.value, **kwargs)
2024-06-20 16:17:53.080   File "/usr/lib/python3.10/subprocess.py", line 503, in run
2024-06-20 16:17:53.080     with Popen(*popenargs, **kwargs) as process:
2024-06-20 16:17:53.080   File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
2024-06-20 16:17:53.080     self._execute_child(args, executable, preexec_fn, close_fds,
2024-06-20 16:17:53.080   File "/usr/lib/python3.10/subprocess.py", line 1863, in _execute_child
2024-06-20 16:17:53.080     raise child_exception_type(errno_num, err_msg, err_filename)
2024-06-20 16:17:53.080 FileNotFoundError: [Errno 2] No such file or directory: 'lxc'
@mr-cal mr-cal added Enhancement New feature or request triaged We will be doing this labels Jun 20, 2024
Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-3042.

This message was autogenerated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request triaged We will be doing this
Projects
None yet
Development

No branches or pull requests

1 participant