Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lxc - Missing source path "/root/snap/charmcraft/common/cache/charmcraft/charmcraft-buildd-base-v7/BuilddBaseAlias.JAMMY/pip" #2107

Open
mcfly722 opened this issue Jan 23, 2025 · 3 comments
Assignees
Labels
Bug Something isn't working triaged

Comments

@mcfly722
Copy link

mcfly722 commented Jan 23, 2025

Bug Description

Hello,
we are using lxd cluster and trying to pack a new created empty charm from scratch, but it fails with error:

'lxc --project charmcraft config device add local:charmcraft-test-on-amd64-for-amd64-2359335 disk-/root/.cache/pip disk source=/root/snap/charmcraft/common/cache/charmcraft/charmcraft-buildd-base-v7/BuilddBaseAlias.JAMMY/pip path=/root/.cache/pip'
2025-01-23 16:37:27.353 * Command exit code: 1
2025-01-23 16:37:27.353 * Command standard error output: b'Error: Failed add validation for device "disk-/root/.cache/pip": Missing source path "/root/snap/charmcraft/common/cache/charmcraft/charmcraft-buildd-base-v7/BuilddBaseAlias.JAMMY/pip" for disk "disk-/root/.cache/pip"\n'

pip installed

folder /root/snap/charmcraft/common/cache/charmcraft/charmcraft-buildd-base-v7/BuilddBaseAlias.JAMMY/pip exist.

To Reproduce

sudo apt install pip

sudo snap install charmcraft --classic

mkdir test
cd test

charmcraft init
charmcraft pack 

Environment

sudo snap list
Name               Version          Rev    Tracking       Publisher   Notes
bare               1.0              5      latest/stable  canonical✓  base
charmcraft         3.2.2            5303   latest/stable  canonical✓  classic
core20             20240911         2434   latest/stable  canonical✓  base
core22             20241119         1722   latest/stable  canonical✓  base
core24             20241119         716    latest/stable  canonical✓  base
gnome-42-2204      0+git.38ea591    202    latest/stable  canonical✓  -
gtk-common-themes  0.1-81-g442e511  1535   latest/stable  canonical✓  -
juju               3.4.6            28491  3.4/stable     canonical✓  -
lxd                5.0.4-497fe1e    31333  5.0/stable/…   canonical✓  -
snapd              2.67             23545  latest/stable  canonical✓  snapd
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.5 LTS
Release:        22.04
Codename:       jammy
pip --version
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)
lxc --project charmcraft list
+---------------------------------------------------------------+---------+---------------------+------+-----------+-----------+--------------+
|                             NAME                              |  STATE  |        IPV4         | IPV6 |   TYPE    | SNAPSHOTS |   LOCATION   |
+---------------------------------------------------------------+---------+---------------------+------+-----------+-----------+--------------+
| base-instance-charmcraft-buildd-base-v7--910533fdd664bd2cdbe9 | STOPPED |                     |      | CONTAINER | 0         | mkhn-jj-tst1 |
+---------------------------------------------------------------+---------+---------------------+------+-----------+-----------+--------------+
| charmcraft-test-on-amd64-for-amd64-2359335                    | RUNNING | 10.68.84.107 (eth0) |      | CONTAINER | 0         | mkhn-jj-tst2 |
+---------------------------------------------------------------+---------+---------------------+------+-----------+-----------+--------------+
lxc --project charmcraft profile show default
config: {}
description: ""
devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: br0
    type: nic
  root:
    path: /
    pool: local
    type: disk
name: default
used_by:
- /1.0/instances/base-instance-charmcraft-buildd-base-v7--910533fdd664bd2cdbe9?project=charmcraft
- /1.0/instances/charmcraft-test-on-amd64-for-amd64-2359335?project=charmcraft

charmcraft.yaml

default, no any changes after

charmcraft init

Relevant log output

2025-01-23 16:37:27.352 Traceback (most recent call last):
2025-01-23 16:37:27.353   File "/snap/charmcraft/5303/lib/python3.10/site-packages/craft_providers/lxd/lxc.py", line 139, in config_device_add_disk
2025-01-23 16:37:27.353     self._run_lxc(command, capture_output=True, project=project)
2025-01-23 16:37:27.353   File "/snap/charmcraft/5303/lib/python3.10/site-packages/craft_providers/lxd/lxc.py", line 104, in _run_lxc
2025-01-23 16:37:27.353     return subprocess.run(lxc_cmd, check=check, stdin=stdin.value, **kwargs)
2025-01-23 16:37:27.353   File "/snap/charmcraft/5303/usr/lib/python3.10/subprocess.py", line 526, in run
2025-01-23 16:37:27.353     raise CalledProcessError(retcode, process.args,
2025-01-23 16:37:27.353 subprocess.CalledProcessError: Command '['lxc', '--project', 'charmcraft', 'config', 'device', 'add', 'local:charmcraft-test-on-amd64-for-amd64-2359335', 'disk-/root/.cache/pip', 'disk', 'source=/root/snap/charmcraft/common/cache/charmcraft/charmcraft-buildd-base-v7/BuilddBaseAlias.JAMMY/pip', 'path=/root/.cache/pip']' returned non-zero exit status 1.
2025-01-23 16:37:27.353
2025-01-23 16:37:27.353 The above exception was the direct cause of the following exception:
2025-01-23 16:37:27.353 Traceback (most recent call last):
2025-01-23 16:37:27.353   File "/snap/charmcraft/5303/lib/python3.10/site-packages/craft_application/application.py", line 543, in run
2025-01-23 16:37:27.353     self.run_managed(platform, build_for)
2025-01-23 16:37:27.353   File "/snap/charmcraft/5303/lib/python3.10/site-packages/charmcraft/application/main.py", line 154, in run_managed
2025-01-23 16:37:27.353     super().run_managed(platform, build_for)
2025-01-23 16:37:27.353   File "/snap/charmcraft/5303/lib/python3.10/site-packages/craft_application/application.py", line 368, in run_managed
2025-01-23 16:37:27.353     with self.services.provider.instance(
2025-01-23 16:37:27.353   File "/snap/charmcraft/5303/usr/lib/python3.10/contextlib.py", line 135, in __enter__
2025-01-23 16:37:27.353     return next(self.gen)
2025-01-23 16:37:27.353   File "/snap/charmcraft/5303/lib/python3.10/site-packages/charmcraft/services/provider.py", line 119, in instance
2025-01-23 16:37:27.353     with super().instance(
2025-01-23 16:37:27.353   File "/snap/charmcraft/5303/usr/lib/python3.10/contextlib.py", line 135, in __enter__
2025-01-23 16:37:27.353     return next(self.gen)
2025-01-23 16:37:27.353   File "/snap/charmcraft/5303/lib/python3.10/site-packages/craft_application/services/provider.py", line 129, in instance
2025-01-23 16:37:27.353     with provider.launched_environment(
2025-01-23 16:37:27.353   File "/snap/charmcraft/5303/usr/lib/python3.10/contextlib.py", line 135, in __enter__
2025-01-23 16:37:27.353     return next(self.gen)
2025-01-23 16:37:27.353   File "/snap/charmcraft/5303/lib/python3.10/site-packages/craft_providers/lxd/lxd_provider.py", line 143, in launched_environment
2025-01-23 16:37:27.353     instance = launch(
2025-01-23 16:37:27.353   File "/snap/charmcraft/5303/lib/python3.10/site-packages/craft_providers/lxd/launcher.py", line 783, in launch
2025-01-23 16:37:27.353     _create_instance(
2025-01-23 16:37:27.353   File "/snap/charmcraft/5303/lib/python3.10/site-packages/craft_providers/lxd/launcher.py", line 229, in _create_instance
2025-01-23 16:37:27.353     base_configuration.warmup(executor=instance)
2025-01-23 16:37:27.353   File "/snap/charmcraft/5303/lib/python3.10/site-packages/craft_providers/base.py", line 1088, in warmup
2025-01-23 16:37:27.353     self._mount_shared_cache_dirs(executor=executor)
2025-01-23 16:37:27.353   File "/snap/charmcraft/5303/lib/python3.10/site-packages/craft_providers/base.py", line 838, in _mount_shared_cache_dirs
2025-01-23 16:37:27.353     executor.mount(host_source=host_pip_cache_path, target=guest_pip_cache_path)
2025-01-23 16:37:27.353   File "/snap/charmcraft/5303/lib/python3.10/site-packages/craft_providers/lxd/lxd_instance.py", line 437, in mount
2025-01-23 16:37:27.353     self.lxc.config_device_add_disk(
2025-01-23 16:37:27.353   File "/snap/charmcraft/5303/lib/python3.10/site-packages/craft_providers/lxd/lxc.py", line 141, in config_device_add_disk
2025-01-23 16:37:27.353     raise LXDError(
2025-01-23 16:37:27.353 craft_providers.lxd.errors.LXDError: Failed to add disk to instance 'charmcraft-test-on-amd64-for-amd64-2359335'.
2025-01-23 16:37:27.353 * Command that failed: 'lxc --project charmcraft config device add local:charmcraft-test-on-amd64-for-amd64-2359335 disk-/root/.cache/pip disk source=/root/snap/charmcraft/common/cache/charmcraft/charmcraft-buildd-base-v7/BuilddBaseAlias.JAMMY/pip path=/root/.cache/pip'
2025-01-23 16:37:27.353 * Command exit code: 1
2025-01-23 16:37:27.353 * Command standard error output: b'Error: Failed add validation for device "disk-/root/.cache/pip": Missing source path "/root/snap/charmcraft/common/cache/charmcraft/charmcraft-buildd-base-v7/BuilddBaseAlias.JAMMY/pip" for disk "disk-/root/.cache/pip"\n'
2025-01-23 16:37:27.353 Full execution log: '/root/.local/state/charmcraft/log/charmcraft-20250123-163454.690259.log'
@mcfly722 mcfly722 added the Bug Something isn't working label Jan 23, 2025
@mcfly722
Copy link
Author

looks like problem occurs because lxc cluster have second node where new container deploys.

installing pip & charmcraft on second node does not help.

I just moved container to first node:

lxc stop charmcraft-test-on-amd64-for-amd64-2359335
lxc move charmcraft-test-on-amd64-for-amd64-2359335 --target mkhn-jj-tst1

# do not start container through lxc manually! just use 'charmcraft pack'

and then

charmcraft pack

successfully builded this charm

@lengau
Copy link
Collaborator

lengau commented Jan 24, 2025

Hi, thanks for the report!

While we don't currently support using Charmcraft in LXD clusters, this is a fairly unexpected breakage.

As a workaround, you can probably run the following on the second node:

mkdir -p /root/snap/charmcraft/common/cache/charmcraft/charmcraft-buildd-base-v7/BuilddBaseAlias.JAMMY/pip

You can also change the directory of the shared cache (defaulting the charmcraft cache directory, in this case /root/snap/charmcraft/common/cache/) by setting the CRAFT_SHARED_CACHE environment variable. More usage info is available in the Charmcraft documentation.

However, I'm not sure whether this is a sustainable operation, as you may need to create subdirectories for each Ubuntu base and each time we make incompatible changes in craft-providers. It may be better to disable caching altogether.

Would it work for you if an upcoming patch release of Charmcraft would accept setting the environment variable CRAFT_SHARED_CACHE to an empty string to disable caching?

@lengau lengau added the triaged label Jan 29, 2025
@lengau lengau self-assigned this Jan 29, 2025
Copy link

Thank you for reporting your feedback to us!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-4039.

This message was autogenerated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working triaged
Projects
None yet
Development

No branches or pull requests

2 participants