← Back to issue list

lxd: split container classes into different files

View original Github issue

Metadata

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

Current evaluation

Merged in snapcraft#1627 via d2118855c, splitting LXD container classes into separate modules, relocating Cleanbuilder methods and deduplicating environment setup without functional changes.

Resolution: closed resolved

Reason: PR #1627 was approved and merged as commit d2118855c. It separated Containerbuild, Cleanbuilder and Project while preserving existing behavior.

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`? ----- As lxd.py has been growing continously I'm splitting it up into one file per class in its own module. That's the Containerbuild base class, Cleanbuilder and Project. I'm using the opportunity to move the Cleanbuilder-specific methods _push_file, _pull_file, _setup_project and _finish out of the Containerbuild class, where before the separation was poor. I'm also de-duplicating calls to set environment variables. Also as a side effect of this split I had to stop importing subprocess functions and sleep by name because unittest.mock couldn't override them for the whole module and patching all the individual files would have been complex and error prone. There's no change in functionality here.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Merged in snapcraft#1627 via d2118855c, splitting LXD container classes into separate modules, relocating Cleanbuilder methods and deduplicating environment setup without functional changes.
stealth/space-bunny-alpha — closed resolved Merged PR #1627 (commit d2118855c) split lxd.py into per-class modules (Containerbuild, Cleanbuilder, Project), moved Cleanbuilder-specific methods and de-duplicated env var setup; no functional change.
stealth/space-bunny-alpha — closed resolved Merged PR #1627 (commit d2118855c) split LXD container classes into separate modules, moved Cleanbuilder methods and deduplicated environment setup without changing functionality.
qwen/qwen3.6-35b-a3b — — Merged refactoring splitting LXD container classes from lxd.py into separate modules. Improves organization, moves Cleanbuilder methods, de-duplicates env vars, and fixes mocking imports. No functional changes. Approved by two reviewers and passed CI.
qwen3.6-35b-a3b-mtp-q6 — — Merged a refactoring splitting lxd.py into separate modules for Containerbuild, Cleanbuilder, and Project classes. Improves organization, moves methods appropriately, de-duplicates env variable handling, and fixes unittest.mock compatibility. No functional changes.

Update history

No update history recorded yet.

Related work

  • Related To: snapcraft#1230 (confidence 85%)

    Earlier merged refactor introduced the Containerbuild and Project classes reorganized by #1627.

Related issues

Issue Project State Summary Similarity
#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.
78%
#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.
74%
#1364 lxd: Inject snapcraft and core snaps into the container snapcraft merged Merged PR #1364 as 99f5598ac, injecting the host's Snapcraft and core snaps into LXD containers so builds no longer use a mismatched Xenial archive version.
74%
#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.
73%
#1263 lxd: pass through commands into the container snapcraft merged Merged #1263 as commit e0f28bd5c, routing snap-building and parts commands through LXD containers so remote/cleanbuild commands run inside the container environment.
72%
#1587 lifecycle: clean after deleting container snapcraft merged 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.
72%
#2095 lxd: proper error classes for container errors snapcraft merged Merged as caf555acb, introducing dedicated LXD error classes, improving architecture lookup error handling, and adding unit tests.
71%