From bf4d76011ac18047f2effd350555eb5fa5f0d9bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20C=2E=20Mass=C3=B3n?= <939888+Abuelodelanada@users.noreply.github.com> Date: Thu, 19 Sep 2024 10:48:25 -0300 Subject: [PATCH] use loki_push_api v1 (#459) * use loki_push_api v1 * update libs --- lib/charms/tempo_k8s/v2/tracing.py | 13 +++++++++++-- src/charm.py | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/charms/tempo_k8s/v2/tracing.py b/lib/charms/tempo_k8s/v2/tracing.py index d3a7c943e..81bf1f1f5 100644 --- a/lib/charms/tempo_k8s/v2/tracing.py +++ b/lib/charms/tempo_k8s/v2/tracing.py @@ -107,7 +107,7 @@ def __init__(self, *args): # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 9 +LIBPATCH = 10 PYDEPS = ["pydantic"] @@ -902,7 +902,16 @@ def _get_endpoint( def get_endpoint( self, protocol: ReceiverProtocol, relation: Optional[Relation] = None ) -> Optional[str]: - """Receiver endpoint for the given protocol.""" + """Receiver endpoint for the given protocol. + + It could happen that this function gets called before the provider publishes the endpoints. + In such a scenario, if a non-leader unit calls this function, a permission denied exception will be raised due to + restricted access. To prevent this, this function needs to be guarded by the `is_ready` check. + + Raises: + ProtocolNotRequestedError: + If the charm unit is the leader unit and attempts to obtain an endpoint for a protocol it did not request. + """ endpoint = self._get_endpoint(relation or self._relation, protocol=protocol) if not endpoint: requested_protocols = set() diff --git a/src/charm.py b/src/charm.py index 60214e912..5bd114614 100755 --- a/src/charm.py +++ b/src/charm.py @@ -31,7 +31,7 @@ from charms.grafana_k8s.v0.grafana_dashboard import GrafanaDashboardProvider from charms.grafana_k8s.v0.grafana_source import GrafanaSourceProvider from charms.loki_k8s.v0.charm_logging import log_charm -from charms.loki_k8s.v0.loki_push_api import ( +from charms.loki_k8s.v1.loki_push_api import ( LokiPushApiAlertRulesChanged, LokiPushApiProvider, )