Skip to content

fix: install lxd snap only when snap list lxd reports absent#6626

Merged
blackboxsw merged 1 commit into
canonical:mainfrom
blackboxsw:lp-2136198-lxd-preseed
Dec 19, 2025
Merged

fix: install lxd snap only when snap list lxd reports absent#6626
blackboxsw merged 1 commit into
canonical:mainfrom
blackboxsw:lp-2136198-lxd-preseed

Conversation

@blackboxsw
Copy link
Copy Markdown
Collaborator

@blackboxsw blackboxsw commented Dec 15, 2025

To ease the process of reviewing your PR, do make sure to complete the following checklist before submitting a pull request.

  • I have signed the CLA: https://ubuntu.com/legal/contributors
  • I have included a comprehensive commit message using the guide below
  • I have added unit tests to cover the new behavior under tests/unittests/
    • Test files should map to source files i.e. a source file cloudinit/example.py should be tested by tests/unittests/test_example.py
    • Run unit tests with tox -e py3
  • I have kept the change small, avoiding unnecessary whitespace or non-functional changes.
  • I have added a reference to issues that this PR relates to in the PR message (Refs integration: do not LXD bind mount /etc/cloud/cloud.cfg.d #1234, Fixes integration: do not LXD bind mount /etc/cloud/cloud.cfg.d #1234)
  • I have updated the documentation with the changed behavior.
    • If the change doesn't change the user interface and is trivial, this step may be skipped.
    • Cloud-config documentation is generated from the jsonschema.
    • Generate docs with tox -e doc.

Proposed Commit Message

    fix: install lxd snap only when snap list lxd reports absent
    
    Enable cloud-init to 'snap install lxd' when 'snap list lxd' reports
    that the lxd snap is not available. Do not rely on which('lxd') because
    lxd-installer deb package delivers this script, not the lxd snap.
    
    Prior to Ubuntu Plucky, lxd-installer /usr/sbin/lxd would automatically
    install lxd snap if it wasn't on the system. In Ubuntu Plucky and newer
    lxd-installer now blocks on a user prompt "Would you like to install
    LXD.. ?" which prevents cloud-init from automatically installing LXD
    snap.
    
    LP: #2136198

Additional Context

Test Steps

CLOUD_INIT_KEEP_INSTANCE=1 CLOUD_INIT_OS_IMAGE=plucky CLOUD_INIT_CLOUD_INIT_SOURCE=IN_PLACE .tox/integration-tests/bin/pytest  tests/integration_tests/modules/test_lxd.py::test_basic_preseed

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

Copy link
Copy Markdown
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposed commit message is too long, please wrap it.

Has the integration test been failing on plucky since it was released?

Enable cloud-init to 'snap install lxd' when 'snap list lxd' reports
that the lxd snap is not available. Do not rely on which('lxd') because
lxd-installer deb package delivers this script, not the lxd snap.

Prior to Ubuntu Plucky, lxd-installer /usr/sbin/lxd would automatically
install lxd snap if it wasn't on the system. In Ubuntu Plucky and newer
lxd-installer now blocks on a user prompt "Would you like to install
LXD.. ?" which prevents cloud-init from automatically installing LXD
snap.

LP: #2136198
@blackboxsw blackboxsw force-pushed the lp-2136198-lxd-preseed branch from 2ddb2e9 to 99da572 Compare December 15, 2025 23:34
@blackboxsw blackboxsw changed the title fix: install lxd stap only when snap list lxd reports absent fix: install lxd snap only when snap list lxd reports absent Dec 16, 2025

if not subp.which("lxd"):
try:
subp.subp(["snap", "list", "lxd"])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does backwards compatibility for this look on pre-plucky?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good and same behavior from snap list:

root@jj2:~# which lxd
root@jj2:~# snap list lxd
error: no matching snaps installed
root@jj2:~# echo $?
1

---- noble
root@nn:~# which lxd
/usr/sbin/lxd
root@nn:~# snap list lxd
error: no matching snaps installed
root@nn:~# echo $?
1

Copy link
Copy Markdown
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @blackboxsw

@blackboxsw blackboxsw merged commit b117d24 into canonical:main Dec 19, 2025
20 checks passed
MoeSalah1999 pushed a commit to MoeSalah1999/cloud-init that referenced this pull request Dec 19, 2025
…al#6626)

Enable cloud-init to 'snap install lxd' when 'snap list lxd' reports
that the lxd snap is not available. Do not rely on which('lxd') because
lxd-installer deb package delivers this script, not the lxd snap.

Prior to Ubuntu Plucky, lxd-installer /usr/sbin/lxd would automatically
install lxd snap if it wasn't on the system. In Ubuntu Plucky and newer
lxd-installer now blocks on a user prompt "Would you like to install
LXD.. ?" which prevents cloud-init from automatically installing LXD
snap.

LP: #2136198
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants