Skip to content

test: failing reproducer - instance not stopped on setup error - #947

Draft
lengau wants to merge 2 commits into
mainfrom
fix/issue-447-instance-not-stopped-on-error
Draft

test: failing reproducer - instance not stopped on setup error#947
lengau wants to merge 2 commits into
mainfrom
fix/issue-447-instance-not-stopped-on-error

Conversation

@lengau

@lengau lengau commented Apr 22, 2026

Copy link
Copy Markdown
Collaborator

Reproducer for #447 and #757

Adds two failing tests that demonstrate instances are left running when base_configuration.setup() raises an error.

Root cause

In _create_instance() in launcher.py, instance.stop() / base_instance.stop() are only called when setup() succeeds. If setup() raises, the instance is left running.

Failing tests

Fix

Wrap the setup() + stop() calls in _create_instance() in a try/finally block.

Closes #447
Closes #757

Adds two regression tests demonstrating that instances are left
running when base_configuration.setup() raises an error:

- test_instance_stopped_when_setup_fails: regular instance (no base)
- test_base_instance_stopped_when_setup_fails: base instance path

Fixes: #447
Fixes: #757

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lengau

lengau commented Apr 22, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot write a minimal fix for these tests.

Copilot AI commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

@copilot write a minimal fix for these tests.

Done in ee5b1ea. Wrapped the setup() calls in try/finally (base instance path) and try/except (regular instance path) in _create_instance() so stop() is always called when setup() raises. All 53 tests pass, including the two new regression tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

craft-providers leaves base lxd instance running on error Base instance does not stop when setup fails

2 participants