canonical / prometheus-k8s-operator

https://charmhub.io/prometheus-k8s
Apache License 2.0
21 stars 35 forks source link

Fix validation logic #348

Closed sed-i closed 2 years ago

sed-i commented 2 years ago

(This PR was split out of #340.)

Issue

When the bundle is deployed, prometheus is in blocked status (loading config failed) because:

error validating: yaml: unmarshal errors:
  line 4: field name not found in type rulefmt.RuleNode
  line 5: field rules not found in type rulefmt.RuleNode
...

Apparently, when cos tool validation synthesized a tempfile to disk, it created incorrect nesting:

groups:
- name: 5b372040-794c-4e2c-b040-16468d10039d
  rules:
  - name: cos-lite-load-test_7acf3bc5_loki_loki_request_errors_alerts
    rules:
    - alert: LokiRequestErrors

Note the double use of name and rules.

Solution

Using these changes is demonstrated in https://github.com/canonical/cos-configuration-k8s-operator/pull/24.

Context

Load test failed to start after latest releases.

Testing Instructions

Deploy the bundle: juju deploy --channel=edge cos-lite

Release Notes

Fix alert rule validation logic