canonical / cos-proxy-operator

https://charmhub.io/cos-proxy
Apache License 2.0
2 stars 12 forks source link

regenerate nrpe jobs and alert rules on charm upgrade #136

Closed lucabello closed 6 months ago

lucabello commented 6 months ago

Issue

Closes #133.

Solution

Observe the upgrade_charm event to regenerate nrpe alert rules and scrape jobs.

This PR also gets rid of relation_id in the NrpeTargetsChanged event, as it's not used at all.

Testing Instructions

On a machine model:

juju deploy ubuntu
juju deploy nrpe --channel=latest/edge
juju relate ubuntu nrpe

juju deploy cos-proxy --channel=latest/stable --revision=59  # before `absent_over_time`
juju relate cos-proxy nrpe

juju ... # set up a prometheus offer from a k8s model
juju relate cos-proxy prometheus

Check the NRPE alert rules to make sure they are there (and notice how absent_over_time) isn't there; then:

charmcraft pack  # pack the charm from this PR
juju refresh --path=./path-to-the.charm

Check the alert rules again, they should have been updated (and should contain absent_over_time now)