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

Update coordinator to support multiple config generations #115

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ bases:
parts:
charm:
# uncomment this if you add git+ dependencies in requirements.txt:
# build-packages:
# - "git"
build-packages:
- "git"
charm-binary-python-packages:
- "pydantic>=2"
- "cryptography"
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ lightkube>=0.15.4
lightkube-models>=1.24.1.4
tenacity==8.2.3
pydantic>=2
cosl>=0.0.48
# TODO: update when cosl is merged
cosl@git+https://github.com/canonical/cos-lib@publish-version

# crossplane is a package from nginxinc to interact with the Nginx config
crossplane
Expand Down
23 changes: 16 additions & 7 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# See LICENSE file for licensing details.

"""Charmed Operator for Tempo; a lightweight object storage based tracing backend."""

import json
import logging
import re
Expand Down Expand Up @@ -33,7 +34,7 @@
from ops.charm import CharmBase

from nginx_config import NginxConfig
from tempo import Tempo
from tempo import Tempo, TempoConfigBuilderFactory
from tempo_config import TEMPO_ROLES_CONFIG

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -73,7 +74,13 @@ class PeerData(DatabagModel):
@trace_charm(
tracing_endpoint="tempo_otlp_http_endpoint",
server_cert="server_ca_cert",
extra_types=(Tempo, TracingEndpointProvider, Coordinator, ClusterRolesConfig),
extra_types=(
Tempo,
TracingEndpointProvider,
Coordinator,
ClusterRolesConfig,
TempoConfigBuilderFactory,
),
# use PVC path for buffer data, so we don't lose it on pod churn
buffer_path=Path("/tempo-data/.charm_tracing_buffer.raw"),
)
Expand All @@ -88,6 +95,7 @@ def __init__(self, *args):
requested_receivers=self._requested_receivers,
retention_period_hours=self._trace_retention_period_hours,
)
self.tempo_config_factory = TempoConfigBuilderFactory(tempo=self.tempo)
# set alert_rules_path="", as we don't want to populate alert rules into the relation databag
# we only need `self._remote_write.endpoints`
self._remote_write = PrometheusRemoteWriteConsumer(self, alert_rules_path="")
Expand Down Expand Up @@ -117,12 +125,12 @@ def __init__(self, *args):
"catalogue": "catalogue",
},
nginx_config=NginxConfig(server_name=self.hostname).config,
workers_config=self.tempo.config,
workers_config=self.tempo_config_factory.config,
resources_requests=self.get_resources_requests,
container_name="charm",
remote_write_endpoints=self.remote_write_endpoints, # type: ignore
# TODO: future Tempo releases would be using otlp_xx protocols instead.
workload_tracing_protocols=["jaeger_thrift_http"],
# keep jaeger_thrift_http for backward compatibility
workload_tracing_protocols=["otlp_http", "jaeger_thrift_http"],
catalogue_item=self._catalogue_item,
)

Expand All @@ -142,7 +150,8 @@ def __init__(self, *args):

# peer
self.framework.observe(
self.on[PEERS_RELATION_ENDPOINT_NAME].relation_created, self._on_peers_relation_created
self.on[PEERS_RELATION_ENDPOINT_NAME].relation_created,
self._on_peers_relation_created,
)

# refuse to handle any other event as we can't possibly know what to do.
Expand Down Expand Up @@ -226,7 +235,7 @@ def enabled_receivers(self) -> Set[str]:
enabled_receivers = set()
# otlp_http is needed by charm_tracing
enabled_receivers.add("otlp_http")
# jaeger_thrift_http is needed by Tempo's internal workload traces
# backward compatibility for workload traces
enabled_receivers.add("jaeger_thrift_http")
enabled_receivers.update(
[
Expand Down
Loading
Loading