canonical / canonical/cos-proxy-operator
Too many function executions on config-changed event
- Dominant language
- Python
- Stars
- 3
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
### Enhancement Proposal
On a `config-changed` event, cos-proxy executes the same methods `remove_alert_rules` and `set_alert_rule_data` 3 times, where the first iteration seems to be the only valuable one. This can contribute to computational overhead.

I have a suspicion that this is coming from an event loop originating from [nrpe_exporter emitting an `nrpe_targets_changed` event](https://github.com/canonical/cos-proxy-operator/blob/675c1b9fcf3d3bbc20c310740061541b8000a16b/src/nrpe_exporter.py#L321).
The execution chain is as follows:
1. `_regenerate_nrpe` (x1)
2. `remove_alert_rules` (x3)
3. `set_alert_rule_data` (x3)
Then `_regenerate_nrpe` exits, having only executed once.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing the config-changed handling and the nrpe_exporter.py link at line 321, then follow the calls to _regenerate_nrpe, remove_alert_rules, and set_alert_rule_data. Reproduce the event and confirm why the latter methods execute three times; done means the redundant executions are eliminated without changing the intended alert-rule result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100