Skip to content

Commit

Permalink
[DPE-1993] Patroni COS (canonical#261)
Browse files Browse the repository at this point in the history
* Add Patroni COS integration

* Bump libs

* Unit tests

* Scrape IP instead of localhost

* Fix unit tests

* Increase upgrade timout

* Bump libs

* Revert data_interfaces
  • Loading branch information
dragomirp authored Oct 27, 2023
1 parent 8b71e60 commit 8b2669f
Show file tree
Hide file tree
Showing 6 changed files with 3,393 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/charms/data_platform_libs/v0/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def restart(self, event) -> None:
import json
import logging
from abc import ABC, abstractmethod
from typing import List, Literal, Optional, Set, Tuple
from typing import Dict, List, Literal, Optional, Set, Tuple

import poetry.core.constraints.version as poetry_version
from ops.charm import (
Expand All @@ -285,7 +285,7 @@ def restart(self, event) -> None:

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 14
LIBPATCH = 15

PYDEPS = ["pydantic>=1.10,<2", "poetry-core"]

Expand Down Expand Up @@ -346,7 +346,7 @@ class KafkaDependenciesModel(BaseModel):
print(model.dict()) # exporting back validated deps
"""

dependencies: dict[str, str]
dependencies: Dict[str, str]
name: str
upgrade_supported: str
version: str
Expand Down
19 changes: 17 additions & 2 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,27 @@ def __init__(self, *args):
self._observer.start_observer()
self._grafana_agent = COSAgentProvider(
self,
metrics_endpoints=[
{"path": "/metrics", "port": METRICS_PORT},
metrics_endpoints=[{"path": "/metrics", "port": METRICS_PORT}],
scrape_configs=self.patroni_scrape_config,
refresh_events=[
self.on[PEER].relation_changed,
self.on.secret_changed,
self.on.secret_remove,
],
log_slots=[f"{POSTGRESQL_SNAP_NAME}:logs"],
)

def patroni_scrape_config(self) -> List[Dict]:
"""Generates scrape config for the Patroni metrics endpoint."""
return [
{
"metrics_path": "/metrics",
"static_configs": [{"targets": [f"{self._unit_ip}:8008"]}],
"tls_config": {"insecure_skip_verify": True},
"scheme": "https" if self.is_tls_enabled else "http",
}
]

@property
def app_units(self) -> set[Unit]:
"""The peer-related units in the application."""
Expand Down
Loading

0 comments on commit 8b2669f

Please sign in to comment.