← Back to issue list

add `charmcraft purge` or `charmcraft cleanall` command to clean all instances

View original Github issue

Metadata

Project
charmcraft
Number
#1042
Type
issue
State
open
Author
sed-i
Labels
Created
Updated
Closed

Current evaluation

Feature request to add a `charmcraft purge` command to clean all LXD build containers and pip caches. Design discussion is active with multiple flag options proposed. Blocked by craft-providers#639.

Suggested action: keep open

Reason: The issue has active design discussion with multiple maintainer proposals (lengau, paulomach, sed-i) and was explicitly marked as blocked by craft-providers#639 in August 2024. The underlying `purge` function already exists in craft-providers (lxd/project.py), but no `charmcraft purge` command is exposed in the charmcraft codebase. The issue is triaged, scoped, and awaiting the upstream dependency.

Impact: 55 Quick Win: 19.25 Staleness: 40 Complexity: 65 Confidence: 72 Support Request: 10

Issue body

I ran out of space because `/var/snap/lxd/common/lxd/storage-pools/default/containers/charmcraft*` had a lot of stuff in it. ``` $ sudo ls /var/snap/lxd/common/lxd/storage-pools/default/containers charmcraft_base-instance-charmcraft-buildd-base-v00-36b64d8a932634714eb2 charmcraft_charmcraft-grafana-agent-22-0-0-amd64 charmcraft_charmcraft-prometheus-k8s-36-0-0-amd64 charmcraft_base-instance-charmcraft-buildd-base-v00-f36807e72ea445fd8492 charmcraft_charmcraft-grafana-agent-k8s-2-0-0-amd64 charmcraft_charmcraft-pusher-54-0-0-amd64 charmcraft_charmcraft-alertmanager-k8s-5-0-0-amd64 charmcraft_charmcraft-grafana-agent-k8s-22-0-0-amd64 juju-0728c2-2 charmcraft_charmcraft-application-307288-0-0-amd64 charmcraft_charmcraft-kafka-292835-0-0-amd64 juju-0728c2-4 charmcraft_charmcraft-avalanche-k8s-8-0-0-amd64 charmcraft_charmcraft-mimir-k8s-28-0-0-amd64 juju-541575-0 ``` I wonder if it makes sense to add a `--all` flag to `clean` so it will run the equivalent of: ``` sudo bash -c "rm -rf /var/snap/lxd/common/lxd/storage-pools/default/containers/charmcraft*" ``` More precisely, ```bash for instance in $(lxc list --project=charmcraft --format json | jq -r '.[] | select(.name | startswith("charmcraft-")) | .name'); do lxc --project=charmcraft delete $instance done ``` Or, in nushell, ``` (lxc list --project=charmcraft --format json | from json | get name | where { |it| $it | str starts-with 'charmcraft-' } | each { |it| lxc --project=charmcraft delete $it } ) ```

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 55
Quick Win: 19.25
Staleness: 40
Complexity: 65
Confidence: 72
Support Request: 10
keep open Feature request to add a `charmcraft purge` command to clean all LXD build containers and pip caches. Design discussion is active with multiple flag options proposed. Blocked by craft-providers#639.
qwen/qwen3.6-35b-a3b
Staleness: 50
Complexity: 70
Confidence: 90
Support Request: 5
keep open Request to add a charmcraft purge command to clean LXD containers, pip cache, and base images. Currently under discussion with maintainers and blocked by an upstream dependency.
qwen3.6-35b-a3b-mtp-q6
Staleness: 45
Complexity: 65
Confidence: 85
Support Request: 10
keep open Feature request to add a charmcraft purge command to clean LXD containers, pip cache, and base images. Maintainers have proposed a detailed flag structure but the issue is currently blocked by an upstream dependency.
qwen3.6-35b-a3b-mtp-q6
Staleness: 65
Complexity: 60
Confidence: 85
Support Request: 10
keep open Feature request to add a charmcraft purge command for cleaning LXD containers, pip cache, and base images. Scope defined by maintainers, currently blocked by an upstream dependency.
qwen3.6-35b-a3b-mtp-q6
Staleness: 65
Complexity: 40
Confidence: 85
Support Request: 0
keep open Adds a charmcraft purge command to automatically remove LXD containers, pip caches, and base images to free disk space. The team is debating flag behavior and cleanup scope. Currently blocked by an upstream craft-providers dependency.

Update history

No update history recorded yet.

Related work

  • Blocked By: canonical/craft-providers#639 (confidence 90%)

    Explicitly stated by @lengau on 2024-08-26: 'Blocked by https://github.com/canonical/craft-providers/issues/639'

Related issues

Issue Project State Summary Similarity
#412 clean: introduce clean command (CRAFT-62) charmcraft merged Merged. Introduces a clean command to remove LXD containers built by Charmcraft and adds a caplog filter fixture for testing. Approved by two reviewers, the update modifies five files with 116 additions and 4 deletions.
74%
#2078 `charmcraft clean` does not clean all platforms for charm charmcraft open charmcraft clean only removes LXC containers for platforms currently listed in charmcraft.yaml, leaving stale containers for removed platforms. Reported with repro steps; linked to issue #1338 in Jan 2025, no further activity.
70%
#1338 `charmcraft clean` doesn't clean charmcraft closed Unresolved. LXD instances persist after running the command. Behavior changed but remains broken in charmcraft 3. Deferred to upstream craft-application issue #425 for resolution.
70%