Add a `prune` method for Providers
Metadata
Current evaluation
Provider pruning was added in merged PR #925 (commit 9836260), with LXD and Multipass implementations plus unit and integration tests.
Resolution: closed resolved
Reason: Merged PR #925 added the abstract Provider.prune API and provider-specific implementations, with tests covering instance scoping and template pruning. The change is recorded in commit 9836260.
Evaluated by: mr-cal-bot
No scores available.
Issue body
### What needs to get done
* Add a new abstract method, `prune`, to the Provider class in craft-providers
* Implement the method in LXDProvider to remove instances for a LXD project
* If `prune_templates` is true, base instances should be removed too
* Implement the method in MultipassProvider to purge all Multipass VMs for the application
* `prune_templates` is ignored for the MultipassProvider since it doesn’t support base instances.
* Integration and unit tests for both Multipass and LXD. The integration tests should:
* Create multiple instances with different bases in that provider, run prune, and check that all of the relevant instances (but only those) were destroyed. This includes creating a separate “unmanaged” VM/container that we check is not destroyed.
* Ensure that you do not delete managed instances from another application that uses craft-providers. (E.g. Snapcraft does not delete Charmcraft instances)
```py
class Provider:
@abstractmethod
def prune(self, *, prune_templates: bool = False):
class LXDProvider(Provider):
def prune(self, *, prune_templates: bool = False):
...
class MultipassProvider(Provider):
def prune(self, *, prune_templates: bool = False):
...
```
### Why it needs to get done
To allow users to prune instances.
Requires https://github.com/canonical/craft-providers/issues/639
Required for https://github.com/canonical/craft-application/issues/991
Required for https://github.com/canonical/charmcraft/issues/1042
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Provider pruning was added in merged PR #925 (commit 9836260), with LXD and Multipass implementations plus unit and integration tests. | |
| stealth/space-bunny-alpha | — | closed resolved | Enhancement implemented: abstract `prune` added to Provider with LXDProvider and MultipassProvider implementations, merged in PR #925 (commit 9836260, "feat(Provider): add prune method"). | |
| stealth/space-bunny-alpha | — | closed resolved | Added project-scoped pruning for LXD and Multipass in merged PR #925, with optional template pruning. | |
| stealth/space-bunny-alpha | — | closed resolved | Provider pruning was implemented for LXD and Multipass in merged PR #925, commit 9836260, including tests. | |
| stealth/space-bunny-alpha | — | closed resolved | Implemented via merged PR #925 (commit 9836260 "feat(Provider): add prune method"): abstract prune() added to Provider with LXDProvider and MultipassProvider implementations plus unit/integration tests; released in craft-providers 3.6.0. | |
| qwen/qwen3.6-35b-a3b | — | closed resolved | Added abstract prune method to Provider class with LXDProvider and MultipassProvider implementations via merged PR #925. |
Update history
| Date | Change |
|---|---|
| created |
Related work
-
Likely Fixed By:
canonical/craft-providers#925
(confidence 100%)
Merged PR feat: add prune method, associated with commit 9836260.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #925 feat: add prune method | craft-providers | merged | Merged PR #925 as commit 9836260, adding Provider.prune with LXD and Multipass implementations and tests; it closes issue #893. | |
| #163 providers: add Provider, LXDProvider, and MultipassProvider classes | craft-providers | merged | Merged Provider, LXDProvider, and MultipassProvider classes via commit fa5a5e7, adding simplified provider error handling and integration tests. | |
| #991 Add a prune-instances command | craft-application | open | Enhancement to add a prune-instances command for removing non-base provider instances. Upstream craft-providers blockers (#639, #893) are now closed; implementation sits in stalled open PR #1058 with 28 unresolved review comments and failing CI. |