From 2fb2a90da8968b633e94e8458029f9cd77992b44 Mon Sep 17 00:00:00 2001 From: michael Date: Tue, 17 Dec 2024 13:54:29 +0200 Subject: [PATCH 1/3] add catalogue relation --- pyproject.toml | 2 +- src/cosl/coordinated_workers/coordinator.py | 14 ++++++++++++++ tox.ini | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a699584..ecddda0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "cosl" -version = "0.0.47" +version = "0.0.48" authors = [ { name = "sed-i", email = "82407168+sed-i@users.noreply.github.com" }, ] diff --git a/src/cosl/coordinated_workers/coordinator.py b/src/cosl/coordinated_workers/coordinator.py index 582f44d..e344d73 100644 --- a/src/cosl/coordinated_workers/coordinator.py +++ b/src/cosl/coordinated_workers/coordinator.py @@ -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 @@ -165,6 +167,7 @@ def _validate_container_name( "send-datasource": Optional[str], "receive-datasource": Optional[str], "s3": str, + "catalogue": Optional[str], }, total=True, ) @@ -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. @@ -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: An application entry sent to catalogue. Raises: ValueError: @@ -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, @@ -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) @@ -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) @property def _peers(self) -> Optional[Set[ops.model.Unit]]: diff --git a/tox.ini b/tox.ini index 6e9e407..6f54bab 100644 --- a/tox.ini +++ b/tox.ini @@ -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 = From a3b7d98fd33cc74f29e70b66a4f6b151fe0cf608 Mon Sep 17 00:00:00 2001 From: michael Date: Tue, 17 Dec 2024 14:02:43 +0200 Subject: [PATCH 2/3] type ignore --- src/cosl/coordinated_workers/coordinator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cosl/coordinated_workers/coordinator.py b/src/cosl/coordinated_workers/coordinator.py index e344d73..7688d2b 100644 --- a/src/cosl/coordinated_workers/coordinator.py +++ b/src/cosl/coordinated_workers/coordinator.py @@ -642,7 +642,7 @@ def _reconcile(self): self._update_nginx_tls_certificates() self.update_cluster() if self.catalogue: - self.catalogue.update_item(item=self._catalogue_item) + self.catalogue.update_item(item=self._catalogue_item) # type: ignore @property def _peers(self) -> Optional[Set[ops.model.Unit]]: From 0cecfca08ba2b0f6da4cd818a75bcc83f018d2dd Mon Sep 17 00:00:00 2001 From: michael Date: Tue, 17 Dec 2024 14:05:48 +0200 Subject: [PATCH 3/3] better desc --- src/cosl/coordinated_workers/coordinator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cosl/coordinated_workers/coordinator.py b/src/cosl/coordinated_workers/coordinator.py index 7688d2b..c2aadc6 100644 --- a/src/cosl/coordinated_workers/coordinator.py +++ b/src/cosl/coordinated_workers/coordinator.py @@ -235,7 +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: An application entry sent to catalogue. + catalogue_item: A catalogue application entry to be sent to catalogue. Raises: ValueError: