canonical / grafana-k8s-operator

This charmed operator automates the operational procedures of running Grafana, an open-source visualization toolkit, on Kubernetes.
https://charmhub.io/grafana-k8s
Apache License 2.0
6 stars 23 forks source link

Implement black box test for certificate_transfer interface #280

Open bencekov opened 9 months ago

bencekov commented 9 months ago

The tests in test_trusted_certificates.py are whitebox tests. A blackbox test would be less brittle and would better cover what we want to cover. Example.

I think a better itest would be

graph LR

self-signed-certs ---|tls-certificates| traefik ---|ingress| prometheus
grafana ---|recv-ca-cert| self-signed-certs
grafana ---|grafana-source| prometheus

The problem is that for some reason querying for datasource health doesn't work:

$ juju run graf/0 get-admin-password
admin-password: jsbSwIxR6Dg6
url: http://graf-0.graf-endpoints.auth2.svc.cluster.local:3000

$ curl "10.1.166.122:3000/api/datasources" -u admin:jsbSwIxR6Dg6 | jq
[
  {
    "id": 1,
    "uid": "P5DE4FBB56E88771A",
    "orgId": 1,
    "name": "juju_auth2_ee15db9c-9f5d-4594-8b77-3a78862775f4_prom_0",
    "type": "prometheus",
    "typeName": "Prometheus",
    "typeLogoUrl": "public/app/plugins/datasource/prometheus/img/prometheus_logo.svg",
    "access": "proxy",
    "url": "http://prom-0.prom-endpoints.auth2.svc.cluster.local:9090",
    "user": "",
    "database": "",
    "basicAuth": false,
    "isDefault": false,
    "jsonData": {
      "timeInterval": "1m",
      "timeout": 300
    },
    "readOnly": true
  }
]

$ curl "10.1.166.122:3000/api/datasources/uid/P5DE4FBB56E88771A/health" -u admin:jsbSwIxR6Dg6 | jq
{
  "message": "Not found",
  "traceID": ""
}

Any ideas?

_Originally posted by @sed-i in https://github.com/canonical/grafana-k8s-operator/pull/279#discussion_r1414881765_ Comment edited for context by @bencekov

sed-i commented 9 months ago

@simskij pointed out that a healthcheck is impl'd but for me the issue still persists.

@simskij also pointed out that prometheus health could be checked via the grafana proxy like so:

$ curl "http://10.1.166.122:3000/api/datasources/proxy/uid/P5DE4FBB56E88771A/-/healthy" -u admin:jsbSwIxR6Dg6
Prometheus Server is Healthy.
lucabello commented 1 month ago

I believe this health check is only implemented in Grafana 10^1, and we're currently using Grafana 9.

Either we upgrade this image, or we perform the health check in the already suggested way.