LXD device gets corrupted when ssh connection is closed
Metadata
Current evaluation
No evaluation has been recorded for this issue yet.
Issue body
### Check existing issues
- [x] I've verified that this bug isn't described by any existing issues.
### Bug description
I'm using a gcloud compute vm to build snaps. Whenever I am closing the ssh connection, or if the gcloud instance shuts down, and I restart it and continue the snapcraft build, LXD fails to find the old device.
### Steps to reproduce
1. Connect to a gcloud compute instance
2. Start Building the snap
3. Stop the build
4. Close the ssh connection and reconnect
5. See this error
### Environment
GCloud Compute instance
Snapcraft: version 8.13.2 revision 16570
LXD: version 5.21.4-9eb1368 revision 36971
### snapcraft.yaml
```yaml
```
### Log output
```shell
Starting instance
2025-12-29 06:54:28.292 Executing on host: lxc --project snapcraft info local:snapcraft-qt-full-amd64-524348
2025-12-29 06:54:28.408 Executing on host: lxc --project snapcraft start local:snapcraft-qt-full-amd64-524348
2025-12-29 06:54:28.540 Failed to start 'snapcraft-qt-full-amd64-524348'.
2025-12-29 06:54:28.540 Detailed information:
* Command that failed: 'lxc --project snapcraft start local:snapcraft-qt-full-amd64-524348'
* Command exit code: 1
* Command standard error output: b'Error: Failed start validation for device "disk-/tmp/craft-state": Missing source path "/run/user/400433789/356321" for disk "disk-/tmp/craft-state"\nTry `lxc info --show-log local:snapcraft-qt-full-amd64-524348` for more info\n'
2025-12-29 06:54:28.555 Traceback (most recent call last):
2025-12-29 06:54:28.555 File "/snap/snapcraft/16570/lib/python3.12/site-packages/craft_providers/lxd/lxc.py", line 1187, in start
2025-12-29 06:54:28.556 self._run_lxc(command, capture_output=True, project=project)
2025-12-29 06:54:28.556 File "/snap/snapcraft/16570/lib/python3.12/site-packages/craft_providers/lxd/lxc.py", line 206, in _run_lxc
2025-12-29 06:54:28.556 return subprocess.run(
2025-12-29 06:54:28.556 ^^^^^^^^^^^^^^^
2025-12-29 06:54:28.556 File "/snap/snapcraft/current/usr/lib/python3.12/subprocess.py", line 571, in run
2025-12-29 06:54:28.556 raise CalledProcessError(retcode, process.args,
2025-12-29 06:54:28.556 subprocess.CalledProcessError: Command '['lxc', '--project', 'snapcraft', 'start', 'local:snapcraft-qt-full-amd64-524348']' returned non-zero exit status 1.
2025-12-29 06:54:28.556
2025-12-29 06:54:28.556 The above exception was the direct cause of the following exception:
2025-12-29 06:54:28.557 Traceback (most recent call last):
2025-12-29 06:54:28.557 File "/snap/snapcraft/16570/lib/python3.12/site-packages/craft_application/application.py", line 663, in run
2025-12-29 06:54:28.557 return_code = self._run_inner()
2025-12-29 06:54:28.557 ^^^^^^^^^^^^^^^^^
2025-12-29 06:54:28.557 File "/snap/snapcraft/16570/lib/python3.12/site-packages/snapcraft/application.py", line 183, in _run_inner
2025-12-29 06:54:28.557 return_code = super()._run_inner()
2025-12-29 06:54:28.557 ^^^^^^^^^^^^^^^^^^^^
2025-12-29 06:54:28.557 File "/snap/snapcraft/16570/lib/python3.12/site-packages/craft_application/application.py", line 640, in _run_inner
2025-12-29 06:54:28.557 return_code = dispatcher.run() or os.EX_OK
2025-12-29 06:54:28.557 ^^^^^^^^^^^^^^^^
2025-12-29 06:54:28.557 File "/snap/snapcraft/16570/lib/python3.12/site-packages/craft_cli/dispatcher.py", line 564, in run
2025-12-29 06:54:28.558 return self._loaded_command.run(self._parsed_command_args)
2025-12-29 06:54:28.558 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-12-29 06:54:28.558 File "/snap/snapcraft/16570/lib/python3.12/site-packages/craft_application/commands/base.py", line 222, in run
2025-12-29 06:54:28.558 result = self._run(parsed_args, **kwargs) or result
2025-12-29 06:54:28.558 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-12-29 06:54:28.558 File "/snap/snapcraft/16570/lib/python3.12/site-packages/snapcraft/commands/lifecycle.py", line 74, in _run
2025-12-29 06:54:28.558 super()._run(parsed_args)
2025-12-29 06:54:28.558 File "/snap/snapcraft/16570/lib/python3.12/site-packages/craft_application/commands/lifecycle.py", line 619, in _run
2025-12-29 06:54:28.558 return super()._run(parsed_args=parsed_args, step_name=step_name)
2025-12-29 06:54:28.558 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-12-29 06:54:28.559 File "/snap/snapcraft/16570/lib/python3.12/site-packages/craft_application/commands/lifecycle.py", line 232, in _run
2025-12-29 06:54:28.559 self._run_manager_for_build_plan(fetch_service_policy)
2025-12-29 06:54:28.559 File "/snap/snapcraft/16570/lib/python3.12/site-packages/craft_application/commands/lifecycle.py", line 97, in _run_manager_for_build_plan
2025-12-29 06:54:28.559 provider.run_managed(build, bool(fetch_service_policy))
2025-12-29 06:54:28.559 File "/snap/snapcraft/16570/lib/python3.12/site-packages/craft_application/services/provider.py", line 457, in run_managed
2025-12-29 06:54:28.559 with self.instance(
2025-12-29 06:54:28.559 File "/snap/snapcraft/current/usr/lib/python3.12/contextlib.py", line 137, in __enter__
2025-12-29 06:54:28.559 return next(self.gen)
2025-12-29 06:54:28.559 ^^^^^^^^^^^^^^
2025-12-29 06:54:28.559 File "/snap/snapcraft/16570/lib/python3.12/site-packages/craft_application/services/provider.py", line 185, in instance
2025-12-29 06:54:28.559 with provider.launched_environment(
2025-12-29 06:54:28.559 File "/snap/snapcraft/current/usr/lib/python3.12/contextlib.py", line 137, in __enter__
2025-12-29 06:54:28.560 return next(self.gen)
2025-12-29 06:54:28.560 ^^^^^^^^^^^^^^
2025-12-29 06:54:28.560 File "/snap/snapcraft/16570/lib/python3.12/site-packages/craft_providers/lxd/lxd_provider.py", line 168, in launched_environment
2025-12-29 06:54:28.560 instance = launch(
2025-12-29 06:54:28.560 ^^^^^^^
2025-12-29 06:54:28.560 File "/snap/snapcraft/16570/lib/python3.12/site-packages/craft_providers/lxd/launcher.py", line 780, in launch
2025-12-29 06:54:28.560 if instance.exists() and _launch_existing_instance(
2025-12-29 06:54:28.560 ^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-12-29 06:54:28.560 File "/snap/snapcraft/16570/lib/python3.12/site-packages/craft_providers/lxd/launcher.py", line 429, in _launch_existing_instance
2025-12-29 06:54:28.560 instance.start()
2025-12-29 06:54:28.560 File "/snap/snapcraft/16570/lib/python3.12/site-packages/craft_providers/lxd/lxd_instance.py", line 568, in start
2025-12-29 06:54:28.560 self.lxc.start(
2025-12-29 06:54:28.561 File "/snap/snapcraft/16570/lib/python3.12/site-packages/craft_providers/lxd/lxc.py", line 1189, in start
2025-12-29 06:54:28.561 raise LXDError(
2025-12-29 06:54:28.561 craft_providers.lxd.errors.LXDError: Failed to start 'snapcraft-qt-full-amd64-524348'.
2025-12-29 06:54:28.561 * Command that failed: 'lxc --project snapcraft start local:snapcraft-qt-full-amd64-524348'
2025-12-29 06:54:28.561 * Command exit code: 1
2025-12-29 06:54:28.561 * Command standard error output: b'Error: Failed start validation for device "disk-/tmp/craft-state": Missing source path "/run/user/400433789/356321" for disk "disk-/tmp/craft-state"\nTry `lxc info --show-log local:snapcraft-qt-full-amd64-524348` for more info\n'
```
Evaluation history
No evaluation history available.