canonical / canonical/cos-proxy-operator
Refactor usage of stored state
- Dominant language
- Python
- Stars
- 3
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
### Enhancement Proposal
Typically, cos-proxy has many incoming relations (e.g. alerts rules from tens/hundreds of units) and few outgoing relations (e.g. downstream prometheus).
For this reason, it takes the model a [long time to settle](https://github.com/canonical/cos-proxy-operator/issues/56), and one of the reasons stored state was introduced - to reduce the total number of `relation-get` calls.
If we were to rewrite cos-proxy a bit, I imagine we'd use stored state in the following way in order to reduce relation-get calls:
- Do not mix alerts in stored state. Instead, keep track of where they came from.
- Untangle the current convolution in code handling stored state <-> reldata flow.

([Playground](https://play.d2lang.com/?script=nFTLjtswDLzrKwj3Vlju7qYnH_oT7THAQrW4thCLMmilRZD43wv5Gb_SNhdDGGo4I2noip1FX-C5lnwusU7hKgAYS-WNI6mVV6IRghgraR0Z73hvT1Yotl1NX0hZk3UtQX6D2jtGnU6krFCUo46PNPXBSrEP2Aj9ZHdCio-UOfow-cASAJ8gR0Le0tjYW3P2ZTrpuyqR_fvfiALGyq26-MKRAAjdvrco1F55bKH2c22_ABFxhbK_gSgdcYCIsZSvAUqSpIlDq87DBzsLgRbuB4yG1znnbeT0-LiIlu-3FjzsCXbLXvEwJ33dUWwEwG0ViGSWhXClbRaSWQz-9fFp8fpCLM-4J_d_IVvraPebas-orJwkH4W9VwwONrlzo8uAxUf6LDe83oF3bu_QwW_nYTUHT1gZjvNwTJ7pK36p4X-h32RXHBJaqos7e4mUG8IUsDz18_UD2RpSJfgCLULmNPaVFpBGp3B4eREhjo34EwAA__8%3D&layout=elk&sketch=0&))
References:
- [Thread on matrix about caching](https://matrix.to/#/!xdClnUGkurzjxqiQcN:ubuntu.com/$EQsrS-KW6ILdF7OWL7iT2W2QyIrKQN0Bfjf_rF8UNTk?via=ubuntu.com&via=matrix.org&via=lgp.sh)
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue names no files, tests, or entry points. Start by tracing the stored-state and relation-data flow, then review the linked caching discussion and the model-settling issue. Done would mean separating alert provenance from stored state, untangling the stored-state/reldata handling, and reducing relation-get calls as proposed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100