Skip to content

Commit 6790adc

Browse files
authored
[DPE-1993] Patroni COS (#261)
* Add Patroni COS integration * Bump libs * Unit tests * Scrape IP instead of localhost * Fix unit tests * Increase upgrade timout * Bump libs * Revert data_interfaces
1 parent f8772a1 commit 6790adc

File tree

6 files changed

+3393
-6
lines changed

6 files changed

+3393
-6
lines changed

lib/charms/data_platform_libs/v0/upgrade.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def restart(self, event) -> None:
263263
import json
264264
import logging
265265
from abc import ABC, abstractmethod
266-
from typing import List, Literal, Optional, Set, Tuple
266+
from typing import Dict, List, Literal, Optional, Set, Tuple
267267

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

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

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

@@ -346,7 +346,7 @@ class KafkaDependenciesModel(BaseModel):
346346
print(model.dict()) # exporting back validated deps
347347
"""
348348

349-
dependencies: dict[str, str]
349+
dependencies: Dict[str, str]
350350
name: str
351351
upgrade_supported: str
352352
version: str

src/charm.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,27 @@ def __init__(self, *args):
144144
self._observer.start_observer()
145145
self._grafana_agent = COSAgentProvider(
146146
self,
147-
metrics_endpoints=[
148-
{"path": "/metrics", "port": METRICS_PORT},
147+
metrics_endpoints=[{"path": "/metrics", "port": METRICS_PORT}],
148+
scrape_configs=self.patroni_scrape_config,
149+
refresh_events=[
150+
self.on[PEER].relation_changed,
151+
self.on.secret_changed,
152+
self.on.secret_remove,
149153
],
150154
log_slots=[f"{POSTGRESQL_SNAP_NAME}:logs"],
151155
)
152156

157+
def patroni_scrape_config(self) -> List[Dict]:
158+
"""Generates scrape config for the Patroni metrics endpoint."""
159+
return [
160+
{
161+
"metrics_path": "/metrics",
162+
"static_configs": [{"targets": [f"{self._unit_ip}:8008"]}],
163+
"tls_config": {"insecure_skip_verify": True},
164+
"scheme": "https" if self.is_tls_enabled else "http",
165+
}
166+
]
167+
153168
@property
154169
def app_units(self) -> set[Unit]:
155170
"""The peer-related units in the application."""

0 commit comments

Comments
 (0)