← Back to issue list

lxd: launch instances from local instance instead of image

View original Github issue

Metadata

Project
craft-providers
Number
#177
Type
pull request
State
merged
Author
mr-cal
Labels
—
Created
Updated
Closed

Current evaluation

Merged PR #177 (commit cd70943) refactoring craft_providers/lxd/launcher.py to cache configured LXD environments as a base instance instead of an image, cutting launch time ~19-34s. Deprecates use_snapshots in favor of use_base_instance. (CRAFT-1339)

Resolution: closed resolved

Reason: PR #177 was approved and merged into main as commit cd70943, delivering the base-instance mechanism described in the description. Follow-ups #178 (test refactor), #187, and #202 (adopting use_base_instance) landed on top, and the deprecated parameter was later removed in c258e02.

Evaluated by: mr-cal-bot

No scores available.

Issue body

- [X] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)? ----- ## Overview Cache a configured LXD environment as an instance instead of an image. ## Details On the first run of an application, an instance will be launched from an image (i.e. an image from https://cloud-images.ubuntu.com). The instance is then setup. After setup, a copy of this instance is saved (or cached) as a 'base instance'. This is done to reduce setup time on subsequent runs. When the application requests a new instance on a subsequent run, the base instance will be copied to create the new instance. This instance is run through a small subset of the setup, which is referred to as 'warmup'. ## Previous behavior ![image](https://user-images.githubusercontent.com/60674096/205115452-774be7af-ebdc-44ab-b955-3e7f3e8b542b.png) ## New behavior The flowchart below describes the logic inside the `launch()` call. The flowchart has become crowded as it's evolved - it's a result of the fixed drawing size in Google Doc's embedded drawings. ![image](https://user-images.githubusercontent.com/60674096/205114903-3c2d7a1b-506b-46bc-b6b0-406090b88b99.png) ## Notes on the PR - `craft_providers/lxd/launcher.py` was completely refactored, since the underlying mechanism was redone. It's may be easier to review the new file instead of the diff. - The unit tests did not need to be changed dramatically (thanks to https://github.com/canonical/craft-providers/pull/178). However I added more tests. - The integration tests are mostly unchanged too, aside from swapping `base image` assertions for `base instance` assertions. - I've added a deprecation warning for the parameter `use_snapshots` in favor of `use_base_instance`. For now, the old parameter will still work but will log a warning. ## Performance improvement The scenarios below were measure how long the call to `lxd.launch()` takes when building a simple snap on a typical developer laptop. | scenario | previous time | new time | speed up | |-----|------|----------|-----| |clean environment|01:58.415|01:24:483|34 seconds| |base instance exists|00:24.721|00:04.886|19 seconds| |instance exists|00:04:145|00:04.194|no change| (CRAFT-1339)

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Merged PR #177 (commit cd70943) refactoring craft_providers/lxd/launcher.py to cache configured LXD environments as a base instance instead of an image, cutting launch time ~19-34s. Deprecates use_snapshots in favor of use_base_instance. (CRAFT-1339)
qwen/qwen3.6-35b-a3b — closed resolved Refactored craft_providers/lxd/launcher.py to cache configured LXD environments as a base instance instead of an image, reducing setup time and deprecating use_snapshots in favor of use_base_instance (CRAFT-1339).

Update history

Date Change
created

Related work

  • Likely Fixed By: canonical/craft-providers#178 (confidence 85%)

    Merged test refactor cited in PR #177 body as prerequisite; it enabled testing the new base-instance launcher.

  • Related To: canonical/craft-providers#202 (confidence 80%)

    Merged as commit fd23832; wires the new use_base_instance parameter through LXDProvider launches.

  • Related To: canonical/craft-providers#187 (confidence 70%)

    Merged as commit b0df595; adds base-instance assertions and an lxc.info() integration test for the merged behavior.

Related issues

Issue Project State Summary Similarity
#202 lxd: use new `use_base_instance` parameter craft-providers merged Merged in PR #202 as commit fd23832, forwarding use_base_instance for LXDProvider launches; included in craft-providers 1.8.0.
76%