Open relaxdiego opened 4 years ago
Further investigation shows that the most effective way is to get the current config on disk mounted on /etc/prometheus/prometheus.yaml
in the prometheus
container. However, this requires opening a websocket connection to the k8s APIServer in the path /api/v1/namespaces/{namespace}/pods/{pod_name}/exec
. Python's httplib does not natively support websockets.
Another option is to set the config template such that it explicitly sets the optional configuration values. However, this will only work for as long as Prometheus doesn't change its config schema.
Because
domain.check_config_propagation()
uses the Prometheus API to get the current config:https://github.com/charmed-lma/charm-k8s-prometheus/blob/f23289f99a00439162ebaf5f9daaf03b457722fe/src/domain.py#L426-L429
current_config
will actually be the effective configuration as loaded in memory. This effective configuration will be equal toexpected_config
plus some optional configuration options that Prometheus will have set to their default values. Thus the following line will always returnFalse
https://github.com/charmed-lma/charm-k8s-prometheus/blob/f23289f99a00439162ebaf5f9daaf03b457722fe/src/domain.py#L443