diff --git a/lib/charms/data_platform_libs/v0/data_interfaces.py b/lib/charms/data_platform_libs/v0/data_interfaces.py index 7314689c38..109603ad49 100644 --- a/lib/charms/data_platform_libs/v0/data_interfaces.py +++ b/lib/charms/data_platform_libs/v0/data_interfaces.py @@ -331,7 +331,7 @@ def _on_topic_requested(self, event: TopicRequestedEvent): # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 47 +LIBPATCH = 49 PYDEPS = ["ops>=2.0.0"] @@ -3527,6 +3527,11 @@ def __init__( self.consumer_group_prefix = consumer_group_prefix or "" self.mtls_cert = mtls_cert + @staticmethod + def is_topic_value_acceptable(topic_value: str) -> bool: + """Check whether the given Kafka topic value is acceptable.""" + return "*" not in topic_value[:3] + @property def topic(self): """Topic to use in Kafka.""" @@ -3534,9 +3539,8 @@ def topic(self): @topic.setter def topic(self, value): - # Avoid wildcards - if value == "*": - raise ValueError(f"Error on topic '{value}', cannot be a wildcard.") + if not self.is_topic_value_acceptable(value): + raise ValueError(f"Error on topic '{value}', unacceptable value.") self._topic = value def set_mtls_cert(self, relation_id: int, mtls_cert: str) -> None: @@ -3760,6 +3764,10 @@ def _on_relation_changed_event(self, event: RelationChangedEvent) -> None: event.relation, app=event.app, unit=event.unit ) + def _on_secret_changed_event(self, event: SecretChangedEvent) -> None: + """Event emitted when the relation data has changed.""" + pass + class OpenSearchProvides(OpenSearchProvidesData, OpenSearchProvidesEventHandlers): """Provider-side of the OpenSearch relation.""" diff --git a/lib/charms/tempo_coordinator_k8s/v0/charm_tracing.py b/lib/charms/tempo_coordinator_k8s/v0/charm_tracing.py index 050e5b384b..61fcf07716 100644 --- a/lib/charms/tempo_coordinator_k8s/v0/charm_tracing.py +++ b/lib/charms/tempo_coordinator_k8s/v0/charm_tracing.py @@ -313,10 +313,10 @@ def _remove_stale_otel_sdk_packages(): import opentelemetry import ops -from opentelemetry.exporter.otlp.proto.common._internal.trace_encoder import ( +from opentelemetry.exporter.otlp.proto.common._internal.trace_encoder import ( # type: ignore encode_spans # type: ignore ) -from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter +from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter # type: ignore from opentelemetry.sdk.resources import Resource from opentelemetry.sdk.trace import ReadableSpan, Span, TracerProvider from opentelemetry.sdk.trace.export import ( @@ -348,7 +348,7 @@ def _remove_stale_otel_sdk_packages(): # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 8 +LIBPATCH = 9 PYDEPS = ["opentelemetry-exporter-otlp-proto-http==1.21.0"] diff --git a/src/charm.py b/src/charm.py index 8848151e04..0afe1b8801 100755 --- a/src/charm.py +++ b/src/charm.py @@ -1961,6 +1961,8 @@ def _was_restore_successful(self) -> bool: logger.debug("Restore check early exit: can't get current wal timeline") return False + self.enable_disable_extensions() + # Remove the restoring backup flag and the restore stanza name. self.app_peer_data.update({ "restoring-backup": "", diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py index 9b9704db1a..ce4c259a59 100644 --- a/tests/unit/test_charm.py +++ b/tests/unit/test_charm.py @@ -908,6 +908,9 @@ def test_on_update_status_after_restore_operation(harness): patch("charm.PostgresqlOperatorCharm.update_config") as _update_config, patch("charm.Patroni.member_started", new_callable=PropertyMock) as _member_started, patch("charm.Patroni.get_member_status") as _get_member_status, + patch( + "charm.PostgresqlOperatorCharm.enable_disable_extensions" + ) as _enable_disable_extensions, ): _get_current_timeline.return_value = "2" rel_id = harness.model.get_relation(PEER).id @@ -926,6 +929,7 @@ def test_on_update_status_after_restore_operation(harness): _oversee_users.assert_not_called() _update_relation_endpoints.assert_not_called() _set_primary_status_message.assert_not_called() + _enable_disable_extensions.assert_not_called() assert isinstance(harness.charm.unit.status, BlockedStatus) # Test when the restore operation hasn't finished yet. @@ -938,6 +942,7 @@ def test_on_update_status_after_restore_operation(harness): _oversee_users.assert_not_called() _update_relation_endpoints.assert_not_called() _set_primary_status_message.assert_not_called() + _enable_disable_extensions.assert_not_called() assert isinstance(harness.charm.unit.status, ActiveStatus) # Assert that the backup id is still in the application relation databag. @@ -956,6 +961,7 @@ def test_on_update_status_after_restore_operation(harness): _oversee_users.assert_called_once() _update_relation_endpoints.assert_called_once() _set_primary_status_message.assert_called_once() + _enable_disable_extensions.assert_called_once_with() assert isinstance(harness.charm.unit.status, ActiveStatus) # Assert that the backup id is not in the application relation databag anymore.