Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add catalogue relation #113

Merged
merged 3 commits into from
Dec 18, 2024
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "cosl"
version = "0.0.47"
version = "0.0.48"
authors = [
{ name = "sed-i", email = "[email protected]" },
]
Expand Down
14 changes: 14 additions & 0 deletions src/cosl/coordinated_workers/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@
"charms.tempo_coordinator_k8s.v0.tracing",
"charms.observability_libs.v0.kubernetes_compute_resources_patch",
"charms.tls_certificates_interface.v3.tls_certificates",
"charms.catalogue_k8s.v1.catalogue",
)

from charms.catalogue_k8s.v1.catalogue import CatalogueConsumer, CatalogueItem
from charms.data_platform_libs.v0.s3 import S3Requirer
from charms.grafana_k8s.v0.grafana_dashboard import GrafanaDashboardProvider
from charms.loki_k8s.v1.loki_push_api import LogForwarder, LokiPushApiConsumer
Expand Down Expand Up @@ -165,6 +167,7 @@ def _validate_container_name(
"send-datasource": Optional[str],
"receive-datasource": Optional[str],
"s3": str,
"catalogue": Optional[str],
},
total=True,
)
Expand Down Expand Up @@ -204,6 +207,7 @@ def __init__(
container_name: Optional[str] = None,
remote_write_endpoints: Optional[Callable[[], List[RemoteWriteEndpoint]]] = None,
workload_tracing_protocols: Optional[List[ReceiverProtocol]] = None,
catalogue_item: Optional[CatalogueItem] = None,
):
"""Constructor for a Coordinator object.

Expand Down Expand Up @@ -231,6 +235,7 @@ def __init__(
and the worker charm can push metrics to.
workload_tracing_protocols: A list of protocols that the worker intends to send
workload traces with.
catalogue_item: A catalogue application entry to be sent to catalogue.

Raises:
ValueError:
Expand Down Expand Up @@ -261,6 +266,7 @@ def __init__(
self._container_name = container_name
self._resources_limit_options = resources_limit_options or {}
self.remote_write_endpoints_getter = remote_write_endpoints
self._catalogue_item = catalogue_item

self.nginx = Nginx(
self._charm,
Expand Down Expand Up @@ -330,6 +336,12 @@ def __init__(
else None
)

self.catalogue = (
CatalogueConsumer(self._charm, item=self._catalogue_item)
if self._endpoints.get("catalogue", None)
else None
)

# We always listen to collect-status
self.framework.observe(self._charm.on.collect_unit_status, self._on_collect_unit_status)

Expand Down Expand Up @@ -629,6 +641,8 @@ def _reconcile(self):

self._update_nginx_tls_certificates()
self.update_cluster()
if self.catalogue:
self.catalogue.update_item(item=self._catalogue_item) # type: ignore

@property
def _peers(self) -> Optional[Set[ops.model.Unit]]:
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ commands =
charmcraft fetch-lib charms.tempo_coordinator_k8s.v0.tracing
charmcraft fetch-lib charms.observability_libs.v0.kubernetes_compute_resources_patch
charmcraft fetch-lib charms.tls_certificates_interface.v3.tls_certificates

charmcraft fetch-lib charms.catalogue_k8s.v1.catalogue

[testenv:fmt]
description = Apply coding style standards to code
deps =
Expand Down
Loading