Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions lib/charms/data_platform_libs/v0/data_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down Expand Up @@ -3527,16 +3527,20 @@ 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."""
return self._topic

@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:
Expand Down Expand Up @@ -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."""
Expand Down
6 changes: 3 additions & 3 deletions lib/charms/tempo_coordinator_k8s/v0/charm_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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"]

Expand Down
2 changes: 2 additions & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down
Loading