canonical / grafana-agent-k8s-operator

https://charmhub.io/grafana-agent-k8s
Apache License 2.0
8 stars 18 forks source link

Support a callable for COSAgentProvider.metrics_endpoints #223

Closed neoaggelos closed 1 year ago

neoaggelos commented 1 year ago

Issue

It may be desired for the metrics endpoints to be generated independently of the lifecycle of the COSAgentProvider object. Some use cases are:

Solution

Allow metrics_endpoints to be a callable instead of a static list. It will be executed only when the object needs to update the scrape jobs.

Context

Needed for https://github.com/canonical/charm-microk8s/pull/88

Testing Instructions

Release Notes

Allow a callable to dynamically generate the metrics endpoints

neoaggelos commented 1 year ago

I see that the integration tests are failing with:

  File "/home/runner/work/grafana-agent-k8s-operator/grafana-agent-k8s-operator/tests/integration/conftest.py", line 89, in prometheus_tester_charm
    charm = await ops_test.build_charm(charm_path)
  File "/home/runner/work/grafana-agent-k8s-operator/grafana-agent-k8s-operator/.tox/integration/lib/python3.10/site-packages/pytest_operator/plugin.py", line 1011, in build_charm
    raise RuntimeError(
RuntimeError: Failed to build charm tests/integration/prometheus-tester:
Packing the charm.
Launching environment to pack for base name='ubuntu' channel='20.04' architectures=['amd64'] (may take a while the first time but it's reusable)
charmcraft internal error: BaseCompatibilityError(brief="Incompatible base detected: Expected OS 'Ubuntu', found None.", details=None, resolution='Clean incompatible instance and retry the requested operation.')

I imagine this is unrelated?