diff --git a/config.yaml b/config.yaml index a985d46..af2a5b8 100644 --- a/config.yaml +++ b/config.yaml @@ -1 +1,10 @@ -options: {} +# Copyright 2023 Canonical Ltd. +# See LICENSE file for licensing details. + +options: + config_file: + type: string + default: "" + description: > + Mimir configuration file (yaml). Refer to + https://grafana.com/docs/mimir/latest/references/configuration-parameters/ for full details. diff --git a/metadata.yaml b/metadata.yaml index 171865c..8d9ca33 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -33,42 +33,8 @@ resources: description: OCI image for Grafana Agent requires: - # On the same mimir_worker interface, the coordinator will accept one relation to a worker per - # each Mimir component. - # The relation(s) determine the role(s) the worker will assume. - # Each Mimir worker can take on multiple roles; however, there can be no role replication among - # workers related to the same coordinator, which is why we force `limit: 1`. - # Note: relation names exactly match Mimir roles. - compactor: - interface: mimir_worker - limit: 1 - distributor: - interface: mimir_worker - limit: 1 - ingester: - interface: mimir_worker - limit: 1 - querier: - interface: mimir_worker - limit: 1 - query-frontend: - interface: mimir_worker - limit: 1 - store-gateway: - interface: mimir_worker - limit: 1 - alertmanager: - interface: mimir_worker - limit: 1 - ruler: - interface: mimir_worker - limit: 1 - overrides-exporter: - interface: mimir_worker - limit: 1 - query-scheduler: - interface: mimir_worker - limit: 1 + mimir-cluster: + interface: mimir_cluster s3: interface: s3 diff --git a/src/mimir_coordinator.py b/src/mimir_coordinator.py index a41320f..f9b7179 100644 --- a/src/mimir_coordinator.py +++ b/src/mimir_coordinator.py @@ -10,7 +10,7 @@ from typing import List, Optional import pydantic -from interfaces.mimir_worker.v0.schema import MimirRole, RequirerSchema +from interfaces.mimir_cluster.v0.schema import MimirRole, RequirerSchema from ops.model import ModelError, Relation, Unit logger = logging.getLogger(__name__) @@ -49,8 +49,9 @@ deployment to be considered robust according to the official recommendations/guidelines.""" -def _endpoint_to_role(endpoint: str) -> MimirRole: - return MimirRole(endpoint.replace("-", "_")) +def _relation_to_role(relation: Relation) -> MimirRole: + # TODO: extract the role from the relation + return MimirRole(relation.role) # FIXME class MimirCoordinator: @@ -77,7 +78,7 @@ def is_recommended(self) -> bool: return True def roles(self) -> typing.Counter[MimirRole]: - """Gather the roles from the mimir_worker relations and count them.""" + """Gather the roles from the mimir_cluster relations and count them.""" roles = Counter() for relation in self.relations: @@ -86,8 +87,10 @@ def roles(self) -> typing.Counter[MimirRole]: continue try: - role = _endpoint_to_role(relation.name) + role = _relation_to_role(relation) # TODO: get the role from relation data + except ValueError: + # TODO: not an actual role: should probably warn logger.info(f"Not a mimir-*role* relation: {relation.name}") continue