Skip to content

Commit 894903c

Browse files
committed
Bump libs
1 parent 3b05eb2 commit 894903c

File tree

5 files changed

+33
-25
lines changed

5 files changed

+33
-25
lines changed

lib/charms/data_platform_libs/v0/data_interfaces.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def _on_topic_requested(self, event: TopicRequestedEvent):
331331

332332
# Increment this PATCH version before using `charmcraft publish-lib` or reset
333333
# to 0 if you are raising the major API version
334-
LIBPATCH = 45
334+
LIBPATCH = 46
335335

336336
PYDEPS = ["ops>=2.0.0"]
337337

@@ -989,11 +989,7 @@ def __init__(
989989
@property
990990
def relations(self) -> List[Relation]:
991991
"""The list of Relation instances associated with this relation_name."""
992-
return [
993-
relation
994-
for relation in self._model.relations[self.relation_name]
995-
if self._is_relation_active(relation)
996-
]
992+
return self._model.relations[self.relation_name]
997993

998994
@property
999995
def secrets_enabled(self):
@@ -1271,15 +1267,6 @@ def _legacy_apply_on_delete(self, fields: List[str]) -> None:
12711267

12721268
# Internal helper methods
12731269

1274-
@staticmethod
1275-
def _is_relation_active(relation: Relation):
1276-
"""Whether the relation is active based on contained data."""
1277-
try:
1278-
_ = repr(relation.data)
1279-
return True
1280-
except (RuntimeError, ModelError):
1281-
return False
1282-
12831270
@staticmethod
12841271
def _is_secret_field(field: str) -> bool:
12851272
"""Is the field in question a secret reference (URI) field or not?"""

lib/charms/loki_k8s/v1/loki_push_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def __init__(self, ...):
546546

547547
# Increment this PATCH version before using `charmcraft publish-lib` or reset
548548
# to 0 if you are raising the major API version
549-
LIBPATCH = 16
549+
LIBPATCH = 17
550550

551551
PYDEPS = ["cosl"]
552552

@@ -1354,7 +1354,7 @@ def _url(self) -> str:
13541354
13551355
Return url to loki, including port number, but without the endpoint subpath.
13561356
"""
1357-
return "http://{}:{}".format(socket.getfqdn(), self.port)
1357+
return f"{self.scheme}://{socket.getfqdn()}:{self.port}"
13581358

13591359
def _endpoint(self, url) -> dict:
13601360
"""Get Loki push API endpoint for a given url.

lib/charms/tempo_coordinator_k8s/v0/charm_tracing.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def _remove_stale_otel_sdk_packages():
314314
import opentelemetry
315315
import ops
316316
from opentelemetry.exporter.otlp.proto.common._internal.trace_encoder import (
317-
encode_spans,
317+
encode_spans # type: ignore
318318
)
319319
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
320320
from opentelemetry.sdk.resources import Resource
@@ -348,7 +348,7 @@ def _remove_stale_otel_sdk_packages():
348348
# Increment this PATCH version before using `charmcraft publish-lib` or reset
349349
# to 0 if you are raising the major API version
350350

351-
LIBPATCH = 7
351+
LIBPATCH = 8
352352

353353
PYDEPS = ["opentelemetry-exporter-otlp-proto-http==1.21.0"]
354354

@@ -704,7 +704,14 @@ def _get_server_cert(
704704
f"{charm_type}.{server_cert_attr} is None; sending traces over INSECURE connection."
705705
)
706706
return
707-
elif not Path(server_cert).is_absolute():
707+
if not isinstance(server_cert, (str, Path)):
708+
logger.warning(
709+
f"{charm_type}.{server_cert_attr} has unexpected type {type(server_cert)}; "
710+
f"sending traces over INSECURE connection."
711+
)
712+
return
713+
path = Path(server_cert)
714+
if not path.is_absolute() or not path.exists():
708715
raise ValueError(
709716
f"{charm_type}.{server_cert_attr} should resolve to a valid tls cert absolute path (string | Path)); "
710717
f"got {server_cert} instead."

lib/charms/tempo_coordinator_k8s/v0/tracing.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def __init__(self, *args):
110110

111111
# Increment this PATCH version before using `charmcraft publish-lib` or reset
112112
# to 0 if you are raising the major API version
113-
LIBPATCH = 7
113+
LIBPATCH = 8
114114

115115
PYDEPS = ["pydantic"]
116116

@@ -169,6 +169,10 @@ class DataValidationError(TracingError):
169169
"""Raised when data validation fails on IPU relation data."""
170170

171171

172+
class DataAccessPermissionError(TracingError):
173+
"""Raised when follower units attempt leader-only operations."""
174+
175+
172176
class AmbiguousRelationUsageError(TracingError):
173177
"""Raised when one wrongly assumes that there can only be one relation on an endpoint."""
174178

@@ -779,7 +783,7 @@ def __init__(
779783
self.framework.observe(events.relation_changed, self._on_tracing_relation_changed)
780784
self.framework.observe(events.relation_broken, self._on_tracing_relation_broken)
781785

782-
if protocols:
786+
if protocols and self._charm.unit.is_leader():
783787
# we can't be sure that the current event context supports read/writing relation data for this relation,
784788
# so we catch ModelErrors. This is because we're doing this in init.
785789
try:
@@ -809,6 +813,8 @@ def request_protocols(
809813
TracingRequirerAppData(
810814
receivers=list(protocols),
811815
).dump(relation.data[self._charm.app])
816+
else:
817+
raise DataAccessPermissionError("only leaders can request_protocols")
812818

813819
@property
814820
def relations(self) -> List[Relation]:
@@ -957,7 +963,15 @@ def charm_tracing_config(
957963
if not endpoint_requirer.is_ready():
958964
return None, None
959965

960-
endpoint = endpoint_requirer.get_endpoint("otlp_http")
966+
try:
967+
endpoint = endpoint_requirer.get_endpoint("otlp_http")
968+
except ModelError as e:
969+
if e.args[0] == "ERROR permission denied\n":
970+
# this can happen the app databag doesn't have data,
971+
# or we're breaking the relation.
972+
return None, None
973+
raise
974+
961975
if not endpoint:
962976
return None, None
963977

lib/charms/tls_certificates_interface/v2/tls_certificates.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,10 @@ def _on_all_certificates_invalidated(self, event: AllCertificatesInvalidatedEven
282282
from typing import Any, Dict, List, Literal, Optional, Union
283283

284284
from cryptography import x509
285-
from cryptography.hazmat._oid import ExtensionOID
286285
from cryptography.hazmat.primitives import hashes, serialization
287286
from cryptography.hazmat.primitives.asymmetric import rsa
288287
from cryptography.hazmat.primitives.serialization import pkcs12
288+
from cryptography.x509.oid import ExtensionOID
289289
from jsonschema import exceptions, validate
290290
from ops.charm import (
291291
CharmBase,
@@ -307,7 +307,7 @@ def _on_all_certificates_invalidated(self, event: AllCertificatesInvalidatedEven
307307

308308
# Increment this PATCH version before using `charmcraft publish-lib` or reset
309309
# to 0 if you are raising the major API version
310-
LIBPATCH = 29
310+
LIBPATCH = 30
311311

312312
PYDEPS = ["cryptography", "jsonschema"]
313313

0 commit comments

Comments
 (0)