Prometheus interface: list index out of range

Bug #1846707 reported by David
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical-OSM
Fix Released
High
David

Bug Description

There's one issue that sometimes happen, and is that the following:

```
application-grafana-k8s: 09:54:36 ERROR unit.grafana-k8s/0.juju-log prometheus:12: Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-grafana-k8s-0/charm/reactive/grafana.py", line 56, in configure
    prometheus_url = prometheus.targets()[0]['targets'][0]
IndexError: list index out of range
```

It seems like the `endpoint.prometheus.available` is set up, but there are no targets yet.

Grafana-k8s code: https://git.launchpad.net/charm-k8s-grafana/tree/reactive/grafana.py

Prometheus-interface code: https://git.launchpad.net/interface-prometheus/tree

Related branches

David (davigar15)
description: updated
Revision history for this message
Cory Johns (johnsca) wrote :

This seems to be running afoul of https://discourse.jujucharms.com/t/caas-network-get-and-private-address-unit-data/ with it likely being the case that the flag is being set before the K8s service is up and thus the ingress-address comes up empty. Because the interface layer only checks the port for setting the flag, it gets the flag set even though there are not actually any targets due to them being filtered out for lack of ingress-address.

The manage_flags code in interface-prometheus's requires side should check `len(self.targets()) > 0` instead of has_port for the two flags.

David (davigar15)
Changed in canonical-osm:
assignee: nobody → David (davigar15)
importance: Undecided → High
status: New → In Progress
Revision history for this message
David (davigar15) wrote :
David (davigar15)
Changed in canonical-osm:
status: In Progress → Fix Committed
David (davigar15)
Changed in canonical-osm:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.