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

Most charms will not be built w/o the rust compiler #989

Closed
DnPlas opened this issue Jul 22, 2024 · 5 comments
Closed

Most charms will not be built w/o the rust compiler #989

DnPlas opened this issue Jul 22, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@DnPlas
Copy link
Contributor

DnPlas commented Jul 22, 2024

Bug Description

Recently the dependency on this toolchain was added via packages like cosl or libraries like the k8s-service-info, though this can happen to any charm that depends on a package that uses the rust compiler to be built from source.

If the rust compiler is not added, charmcraft pack will fail with error: can't find Rust compiler.

To avoid this issue, the following build-packages have to be added to the charmcraft.yaml file:

build-packages: [cargo, rustc, pkg-config, libffi-dev, libssl-dev]

To Reproduce

Build any CKF charm from main or re-try the CI

Environment

Same as CI

Relevant Log Output

::    :: Collecting pydantic-core==2.20.1 (from pydantic->cosl)
::    ::   Downloading pydantic_core-2.20.1.tar.gz (388 kB)
::    ::      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 388.4/388.4 kB 59.3 MB/s eta 0:00:00
::    ::   Installing build dependencies: started
::    ::   Installing build dependencies: finished with status 'error'
::    ::   error: subprocess-exited-with-error
::    ::
::    ::   × pip subprocess to install build dependencies did not run successfully.
::    ::   │ exit code: 1
::    ::   ╰─> [61 lines of output]
::    ::       Collecting maturin<2,>=1
::    ::         Downloading maturin-1.7.0.tar.gz (188 kB)
::    ::            ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 188.3/188.3 kB 34.9 MB/s eta 0:00:00
::    ::         Installing build dependencies: started
::    ::         Installing build dependencies: finished with status 'done'
::    ::         Getting requirements to build wheel: started
::    ::         Getting requirements to build wheel: finished with status 'done'
::    ::         Preparing metadata (pyproject.toml): started
::    ::         Preparing metadata (pyproject.toml): finished with status 'done'
::    ::       Collecting typing-extensions!=4.7.0,>=4.6.0
::    ::         Using cached typing_extensions-4.12.2-py3-none-any.whl
::    ::       Collecting tomli>=1.1.0 (from maturin<2,>=1)
::    ::         Using cached tomli-2.0.1-py3-none-any.whl
::    ::       Building wheels for collected packages: maturin
::    ::         Building wheel for maturin (pyproject.toml): started
::    ::         Building wheel for maturin (pyproject.toml): finished with status 'error'
::    ::         error: subprocess-exited-with-error
::    ::
::    ::         × Building wheel for maturin (pyproject.toml) did not run successfully.
::    ::         │ exit code: 1
::    ::         ╰─> [34 lines of output]
::    ::             running bdist_wheel
::    ::             running build
::    ::             running build_py
::    ::             creating build
::    ::             creating build/lib.linux-x86_64-cpython-38
::    ::             creating build/lib.linux-x86_64-cpython-38/maturin
::    ::             copying maturin/__main__.py -> build/lib.linux-x86_64-cpython-38/maturin
::    ::             copying maturin/__init__.py -> build/lib.linux-x86_64-cpython-38/maturin
::    ::             running egg_info
::    ::             creating maturin.egg-info
::    ::             writing maturin.egg-info/PKG-INFO
::    ::             writing dependency_links to maturin.egg-info/dependency_links.txt
::    ::             writing requirements to maturin.egg-info/requires.txt
::    ::             writing top-level names to maturin.egg-info/top_level.txt
::    ::             writing manifest file 'maturin.egg-info/SOURCES.txt'
::    ::             reading manifest file 'maturin.egg-info/SOURCES.txt'
::    ::             reading manifest template 'MANIFEST.in'
::    ::             /tmp/pip-build-env-1fj3p7m2/overlay/lib/python3.8/site-packages/setuptools/config/_apply_pyprojecttoml.py:79: SetuptoolsWarning: `install_requires` overwritten in `pyproject.toml` (dependencies)
::    ::               corresp(dist, value, root_dir)
::    ::             warning: no files found matching '*.json' under directory 'src/python_interpreter'
::    ::             writing manifest file 'maturin.egg-info/SOURCES.txt'
::    ::             running build_ext
::    ::             running build_rust
::    ::             error: can't find Rust compiler

# It may come from a different package, though.

Additional Context

Example where this is happening.

@DnPlas DnPlas added the bug Something isn't working label Jul 22, 2024
Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/KF-6040.

This message was autogenerated

DnPlas added a commit to canonical/argo-operators that referenced this issue Jul 22, 2024
Adding the rust toolchain and other dependencies to avoid issues at build time.

Part of canonical/bundle-kubeflow#989
DnPlas added a commit to canonical/argo-operators that referenced this issue Jul 22, 2024
Adding the rust toolchain and other dependencies to avoid issues at build time.

Part of canonical/bundle-kubeflow#989
DnPlas added a commit to canonical/knative-operators that referenced this issue Jul 22, 2024
Adding the rust toolchain and other dependencies to avoid issues at build time.

Part of canonical/bundle-kubeflow#989
DnPlas added a commit to canonical/knative-operators that referenced this issue Jul 22, 2024
Adding the rust toolchain and other dependencies to avoid issues at build time.

Part of canonical/bundle-kubeflow#989
@DnPlas
Copy link
Contributor Author

DnPlas commented Jul 22, 2024

I have found something interesting, though. The charms that are failing now are building cosl==0.0.13, which is inconsistent with the pinned version (e.g. argo, knative). This behaviour is odd, and we should look at why the pin is ignored at build time.

EDIT: I have found the following in the build logs

::    :: Installing collected packages: lightkube-models, zipp, websocket-client, urllib3, typing-extensions, tenacity, sniffio, ruamel-yaml-clib, pyyaml, pyr$
istent, pkgutil-resolve-name, ordered-set, markupsafe, idna, h11, exceptiongroup, charset-normalizer, certifi, attrs, ruamel-yaml, requests, ops, jinja2, impo$
tlib-resources, deepdiff, anyio, jsonschema, httpcore, cosl, serialized-data-interface, httpx, lightkube, charmed-kubeflow-chisme
::    :: Successfully installed anyio-4.0.0 attrs-23.1.0 certifi-2023.7.22 charmed-kubeflow-chisme-0.2.0 charset-normalizer-3.2.0 cosl-0.0.12 deepdiff-6.2.1 e$
ceptiongroup-1.1.3 h11-0.14.0 httpcore-0.17.3 httpx-0.24.1 idna-3.4 importlib-resources-6.0.1 jinja2-3.1.2 jsonschema-4.17.3 lightkube-0.14.0 lightkube-models$
1.28.1.4 markupsafe-2.1.3 ops-2.14.0 ordered-set-4.1.0 pkgutil-resolve-name-1.3.10 pyrsistent-0.19.3 pyyaml-6.0.1 requests-2.31.0 ruamel-yaml-0.17.32 ruamel-y$
ml-clib-0.2.7 serialized-data-interface-0.7.0 sniffio-1.3.0 tenacity-8.2.3 typing-extensions-4.11.0 urllib3-2.0.4 websocket-client-1.6.2 zipp-3.16.2
:: Running external command ['/root/parts/charm/build/staging-venv/bin/pip', 'install', '--upgrade', '--no-binary', ':all:', 'cosl']
::    :: Requirement already satisfied: cosl in ./staging-venv/lib/python3.8/site-packages (0.0.12)
::    :: Collecting cosl               
::    ::   Downloading cosl-0.0.14.tar.gz (45 kB)   
::    ::      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 45.7/45.7 kB 1.4 MB/s eta 0:00:00
::    ::   Installing build dependencies: started                                                                                                              
::    ::   Installing build dependencies: finished with status 'done'    
::    ::   Getting requirements to build wheel: started
::    ::   Getting requirements to build wheel: finished with status 'done'
::    ::   Preparing metadata (pyproject.toml): started
::    ::   Preparing metadata (pyproject.toml): finished with status 'done'
::    :: Requirement already satisfied: ops in ./staging-venv/lib/python3.8/site-packages (from cosl) (2.14.0)
::    :: Collecting pydantic (from cosl)                 
::    ::   Downloading pydantic-2.8.2.tar.gz (739 kB)
::    ::      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 739.8/739.8 kB 28.6 MB/s eta 0:00:00                                                                    
::    ::   Installing build dependencies: started                                                                                                             
::    ::   Installing build dependencies: finished with status 'done'
::    ::   Getting requirements to build wheel: started
::    ::   Getting requirements to build wheel: finished with status 'done'                          
::    ::   Preparing metadata (pyproject.toml): started  
::    ::   Preparing metadata (pyproject.toml): finished with status 'done'
::    :: Requirement already satisfied: pyyaml in ./staging-venv/lib/python3.8/site-packages (from cosl) (6.0.1)
::    :: Requirement already satisfied: typing-extensions in ./staging-venv/lib/python3.8/site-packages (from cosl) (4.11.0)
::    :: Requirement already satisfied: websocket-client==1.* in ./staging-venv/lib/python3.8/site-packages (from ops->cosl) (1.6.2)

Turns out the prometheus_scrape.py defines cosl as PYDEPS around L367, which is causing the package to always be pulled from the latest version.

This strange behaviour explains why the CI was not failing last week, as in a latest version of cosl (0.0.13 and 0.0.14) released just last week and today respectively, pydantic was introduced as a dependency.

@DnPlas
Copy link
Contributor Author

DnPlas commented Jul 23, 2024

For reference also look at canonical/charmcraft#1135 (comment)

@DnPlas
Copy link
Contributor Author

DnPlas commented Jul 24, 2024

The issue with the inconsistent cosl versions seems to be fixed in charmcraft 3.1.0, the version in latest/candidate that we use in all CIs. I have tested it locally and the error does not seem to happen any more, BUT now charms are hitting #883. As suggested by @misohu the fix for it now is to bump jinja2 to the latest possible version.

Based on the above then I will proceed with:

  1. Bumping the version of jinja2 in all repositories
  2. No action required for bumping the charmcraft version as our CI already uses latest/candidate

This issue should be closed once we confirm that all CIs are running and potentially we should revert the commits that already introduced rustc and other dependencies as they should not be required.

@DnPlas
Copy link
Contributor Author

DnPlas commented Jul 26, 2024

It was confirmed that charmcraft 3.x fixed the issue with PYDEPS overriding the versions of pkgs in requirements.txt
After applying the changes suggested in my previous comment, I can confirm all CIs are not presenting this issue. Closing it as there is no further action.

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

No branches or pull requests

1 participant