Skip to content

Commit

Permalink
[DPE-4817] Upgrade to use lok_push_api v1 and capture rotated log fil…
Browse files Browse the repository at this point in the history
…es (#283)

## Issue
1. We need to upgrade to loki_push_api v1 to be able to use it in arm64.
Fixes #282
2. We are not uploading rotated log files to loki

## Solution
1. Upgrade charm lib
2. Change log files target to include a regex that will capture both the
mysqlrouter.log and any archived log files

---------

Co-authored-by: Carl Csaposs <carl.csaposs@canonical.com>
  • Loading branch information
shayancanonical and carlcsaposs-canonical committed Jul 11, 2024
1 parent 11080d8 commit c5db3af
Show file tree
Hide file tree
Showing 6 changed files with 541 additions and 279 deletions.
25 changes: 24 additions & 1 deletion 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 = 37
LIBPATCH = 38

PYDEPS = ["ops>=2.0.0"]

Expand Down Expand Up @@ -2606,6 +2606,14 @@ def set_version(self, relation_id: int, version: str) -> None:
"""
self.update_relation_data(relation_id, {"version": version})

def set_subordinated(self, relation_id: int) -> None:
"""Raises the subordinated flag in the application relation databag.
Args:
relation_id: the identifier for a particular relation.
"""
self.update_relation_data(relation_id, {"subordinated": "true"})


class DatabaseProviderEventHandlers(EventHandlers):
"""Provider-side of the database relation handlers."""
Expand Down Expand Up @@ -2842,6 +2850,21 @@ def _on_relation_created_event(self, event: RelationCreatedEvent) -> None:

def _on_relation_changed_event(self, event: RelationChangedEvent) -> None:
"""Event emitted when the database relation has changed."""
is_subordinate = False
remote_unit_data = None
for key in event.relation.data.keys():
if isinstance(key, Unit) and not key.name.startswith(self.charm.app.name):
remote_unit_data = event.relation.data[key]
elif isinstance(key, Application) and key.name != self.charm.app.name:
is_subordinate = event.relation.data[key].get("subordinated") == "true"

if is_subordinate:
if not remote_unit_data:
return

if remote_unit_data.get("state") != "ready":
return

# Check which data has changed to emit customs events.
diff = self._diff(event)

Expand Down
Loading

0 comments on commit c5db3af

Please sign in to comment.