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

ImportError: cannot import name 'x509' from 'cryptography.hazmat.bindings._rust' (unknown location) #241

Open
mcfly722 opened this issue Jan 21, 2025 · 1 comment

Comments

@mcfly722
Copy link

Bug Description

trying to update grafana-agent from 216 to 335 revision failed with exception:

ImportError: cannot import name 'x509' from 'cryptography.hazmat.bindings._rust' (unknown location)

To Reproduce

juju refresh grafana-agent --revision=335

Environment

juju version
3.1.10-genericlinux-amd64
juju controller version=3.1.8
garafana-agent containers [email protected]
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.5 LTS
Release:        22.04
Codename:       jammy

Relevant log output

juju debug-log --include=grafana-agent/26

unit-grafana-agent-23: 12:48:32 ERROR juju.worker.uniter.operation hook "upgrade-charm" (via hook dispatching script: dispatch) failed: exit status 1
unit-grafana-agent-23: 12:48:32 INFO juju.worker.uniter awaiting error resolution for "upgrade-charm" hook
unit-grafana-agent-23: 12:48:36 INFO juju.worker.uniter awaiting error resolution for "upgrade-charm" hook
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm Traceback (most recent call last):
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm   File "/var/lib/juju/agents/unit-grafana-agent-23/charm/lib/charms/observability_libs/v0/cert_handler.py", line 43, in <module>
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm     from charms.tls_certificates_interface.v2.tls_certificates import (  # type: ignore
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm   File "/var/lib/juju/agents/unit-grafana-agent-23/charm/lib/charms/tls_certificates_interface/v2/tls_certificates.py", line 284, in <module>
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm     from cryptography import x509
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm   File "/var/lib/juju/agents/unit-grafana-agent-23/charm/venv/cryptography/x509/__init__.py", line 7, in <module>
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm     from cryptography.x509 import certificate_transparency, verification
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm   File "/var/lib/juju/agents/unit-grafana-agent-23/charm/venv/cryptography/x509/certificate_transparency.py", line 11, in <module>
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm     from cryptography.hazmat.bindings._rust import x509 as rust_x509
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm ImportError: cannot import name 'x509' from 'cryptography.hazmat.bindings._rust' (unknown location)
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm The above exception was the direct cause of the following exception:
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm Traceback (most recent call last):
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm   File "/var/lib/juju/agents/unit-grafana-agent-23/charm/./src/charm.py", line 25, in <module>
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm     from grafana_agent import CONFIG_PATH, METRICS_RULES_SRC_PATH, GrafanaAgentCharm
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm   File "/var/lib/juju/agents/unit-grafana-agent-23/charm/src/grafana_agent.py", line 32, in <module>
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm     from charms.observability_libs.v0.cert_handler import CertHandler
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm   File "/var/lib/juju/agents/unit-grafana-agent-23/charm/lib/charms/observability_libs/v0/cert_handler.py", line 53, in <module>
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm     raise ImportError(
unit-grafana-agent-23: 12:48:36 WARNING unit.grafana-agent/23.upgrade-charm ImportError: failed to import charms.tls_certificates_interface.v2.tls_certificates; Either the library itself is missing (please get it through charmcraft fetch-lib) or one of its dependencies is unmet.

Additional context

No response

@mcfly722
Copy link
Author

rollback using

juju refresh grafana-agent --revision=216

does not work. It has v2 configuration schema, so it cannot rollback to v1.

I also tried to remove-application and redeploy it on last revision=315, but next exception occur:

juju debug-log --include=grafana-agent/45
unit-grafana-agent-45: 15:09:41 WARNING unit.grafana-agent/45.install   File "/var/lib/juju/agents/unit-grafana-agent-45/charm/lib/charms/observability_libs/v0/cert_handler.py", line 53, in <module>
unit-grafana-agent-45: 15:09:41 WARNING unit.grafana-agent/45.install     raise ImportError(
unit-grafana-agent-45: 15:09:41 WARNING unit.grafana-agent/45.install ImportError: failed to import charms.tls_certificates_interface.v2.tls_certificates; Either the library itself is missing (please get it through charmcraft fetch-lib) or one of its dependencies is unmet.
unit-grafana-agent-45: 15:09:42 ERROR juju.worker.uniter.operation hook "install" (via hook dispatching script: dispatch) failed: exit status 1
unit-grafana-agent-45: 15:09:42 INFO juju.worker.uniter awaiting error resolution for "install" hook
unit-grafana-agent-45: 15:14:41 INFO juju.worker.uniter awaiting error resolution for "install" hook
unit-grafana-agent-45: 15:19:38 INFO juju.worker.uniter awaiting error resolution for "install" hook
unit-grafana-agent-45: 15:25:05 INFO juju.worker.uniter awaiting error resolution for "install" hook
unit-grafana-agent-45: 15:30:18 INFO juju.worker.uniter awaiting error resolution for "install" hook
unit-grafana-agent-45: 15:35:47 INFO juju.worker.uniter awaiting error resolution for "install" hook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant