← Back to issue list

lifecycle: clean after deleting container

View original Github issue

Metadata

Project
snapcraft
Number
#1587
Type
pull request
State
merged
Author
kalikiana
Labels
—
Created
Updated
Closed

Current evaluation

Merged PR #1587 (commit daca4618b): LXD cleanup logic moved into lxd.py's clean() so `snapcraft clean` removes leftover build containers, addressing the forum-reported container-build clean issue.

Resolution: closed resolved

Reason: The PR was merged into master as commit daca4618b after reviewers (sergiusens, kyrofa) requested that the business logic be pulled out of the CLI/lifecycle layer and live in the container's clean() method. It fixed `snapcraft clean` not cleaning up after SNAPCRAFT_CONTAINER_BUILDS builds, with follow-up refinements in merged PRs #1655 and #1762.

Evaluated by: mr-cal-bot

No scores available.

Issue body

- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)? - [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)? - [x] If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on [bug reports](https://bugs.launchpad.net/snapcraft)? - [x] If this is a new feature. Have you discussed the design on the [forum](https://forum.snapcraft.io)? - [x] Have you successfully run `./runtests.sh static`? - [x] Have you successfully run `./runtests.sh unit`? ----- See [the forum discussion](https://forum.snapcraft.io/t/snapcraft-clean-doesnt-clean-with-snapcraft-container-builds-set/2291/2).

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Merged PR #1587 (commit daca4618b): LXD cleanup logic moved into lxd.py's clean() so `snapcraft clean` removes leftover build containers, addressing the forum-reported container-build clean issue.
stealth/space-bunny-alpha — closed resolved Merged PR #1587 (commit daca4618b), fixing snapcraft clean after container builds by moving cleanup logic into the container's clean() method.
qwen/qwen3.6-35b-a3b — — Merged after addressing reviewer feedback on logic placement. Fixes snapcraft clean not cleaning up after container builds by moving cleanup logic into the container's clean() method. Branch rebased against master and CI passed.
qwen3.6-35b-a3b-mtp-q6 — — Merged fix for snapcraft clean failing to remove container artifacts. Cleanup logic was refactored into the container module's clean() method per maintainer feedback. Tests passed and branch rebased against master.

Update history

No update history recorded yet.

Related work

  • Related To: snapcraft#1655 (confidence 78%)

    Follow-up merged PR refining the same LXD clean logic so bare clean removes containers while `clean -s pull` preserves them

  • Related To: snapcraft#1762 (confidence 72%)

    Later merged fix by the same author so `clean <part>` only deletes the container when no parts remain, building on this PR's container-clean logic

Related issues

Issue Project State Summary Similarity
#1456 clean up stale containers snapcraft closed Stale LXD build-container cleanup was implemented in merged PR #1587 (commit daca4618b), moving cleanup into the LXD clean lifecycle.
81%
#1762 lxd: delete container only if parts is empty snapcraft merged Merged PR #1762 (dbce9a058), changing LXD cleanup to delete a build container only after all parts are removed, preserving it for targeted cleans and making repeated cleans safe.
77%
#1734145 snapcraft clean <part-name> destroys everything when using containers snapcraft (launchpad) closed Fixed targeted container cleanup: `snapcraft clean <part>` no longer deletes the LXD container while other parts remain; merged in #1762 (dbce9a058).
76%
#1655 lxd: distinguish argless clean from clean -s pull snapcraft merged Merged in snapcraft#1655 (ed32603c7), fixing LXD cleanup so bare clean removes build containers while clean -s pull preserves or recreates them.
75%
#1796980 Remove cleanbuild snapcraft (launchpad) closed Merged snapcore/snapcraft#2335 as 27ec9ba63, removing LXD lifecycle builds for base-based snaps and making cleanbuild redundant for them.
74%
#1434 lxd: clean with no parts should only delete snapcraft merged Merged #1434 in commit 33c7a6bc1, making argless LXD clean delete container resources without executing commands inside the container.
72%
#459 Remove LXD container once we've finished a build snapcraft closed Closed unmerged: testing showed cleanbuild already destroyed its LXD containers; the startup failure was fixed separately by merged PR #458 (f78b1e3a3).
72%
#1627 lxd: split container classes into different files snapcraft merged Merged in snapcraft#1627 via d2118855c, splitting LXD container classes into separate modules, relocating Cleanbuilder methods and deduplicating environment setup without functional changes.
72%
#1230 lxd: refactor Cleanbuilder into Containerbuild and add Project. snapcraft merged Merged PR #1230 (ce66ca561) replaced Cleanbuilder with a Containerbuild base class and added Project to create and reuse project-named LXD containers.
72%
#1746009 clean is checking lxd remote snapcraft (launchpad) closed Snapcraft now initializes the LXD remote lazily, so clean no longer starts a container unnecessarily; fixed by snapcore/snapcraft#1916 (dd4404843).
71%