canonical / grafana-agent-k8s-operator

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

Improve treatment of missing incoming relations #224

Closed sed-i closed 6 months ago

sed-i commented 1 year ago

When relating prom to agent, we get an obscure status message:

App    Version  Status   Scale  Charm              Channel  Rev  Address         Exposed  Message
agent  0.32.1   waiting      1  grafana-agent-k8s  edge      41  10.152.183.253  no       installing agent
prom   2.44.0   active       1  prometheus-k8s     edge     131  10.152.183.97   no

Unit      Workload  Agent  Address     Ports  Message
agent/0*  blocked   idle   10.1.55.22         Missing incoming ('requires') relation
prom/0*   active    idle   10.1.55.39  

Relation provider          Requirer                 Interface                Type     Message
prom:prometheus-peers      prom:prometheus-peers    prometheus_peers         peer
prom:receive-remote-write  agent:send-remote-write  prometheus_remote_write  regular

Need to look at the code to realize that "metrics-endpoint" is required: https://github.com/canonical/grafana-agent-k8s-operator/blob/86c6968639b764d7a0dad63b31bd70dee7024bd7/src/k8s_charm.py#L30-L43

There seem to be a few issues with the code responsible for this:

  1. (bug) has_incoming = True will be set even when not all mandatory rels are in place.
  2. (bug?) Shouldn't block if remote-write is present but metrics-endpoint isn't.
  3. (feature) Need to inform which one exactly is missing.

https://github.com/canonical/grafana-agent-k8s-operator/blob/86c6968639b764d7a0dad63b31bd70dee7024bd7/src/grafana_agent.py#L369-L379

dstathis commented 1 year ago
  1. This is not a bug. We only want to require at least one incoming relation. There is no requirement that you monitor all metrics and logs.
  2. This does not seem to be the case from code inspection. Have you reproduced it?
  3. Yes this definitely needs to be changed.
lucabello commented 6 months ago

Partially duplicates https://github.com/canonical/grafana-agent-k8s-operator/issues/218, it's been solved by https://github.com/canonical/grafana-agent-k8s-operator/pull/286