IFC-2334: Webhook cache invalidation on KeyValue changes#8602
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (4)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
7e55860 to
221c269
Compare
100f6e0 to
8280b6e
Compare
8280b6e to
b8dc72a
Compare
1894daa to
ec78b6f
Compare
ec78b6f to
d582061
Compare
d582061 to
efd1e5b
Compare
|
While doing the application testing, there is a corner case I am thinking about regarding cache management. When a KeyValue update fires One possible solution could be to have the This is a hacky solution. I am not sure if the use case I am describing could be a critical issue for customers, i.e. using old headers in the update request of a |
I'm not sure we need to care about that. The way I see it is that we don't guarantee that a config change takes place immediately. A similar situation would be if you create a webhook from the first place and have it trigger on node creation events then we won't fire a webhook for that specific event. Even with the changes you are making here it could be that we add a header to a webhook and then immediately afterwards we update some other unrelated node. There's a chance that one webhook would fire with the old headers before the new config is applied. I think this is fine as long as the convergence time is short. |
…n layer NodeManager
efd1e5b to
148d8f4
Compare
7120f45 to
a7fe5e6
Compare
Why
When a
CoreKeyValuenode (used as a webhook header) is created, updated, or deleted, the cached webhook configuration becomes stale. Without invalidation, webhooks continue using outdated header values until the cache naturally expires or the server restarts.Based on #8590 and #8597.
Closes IFC-2334
What changed
invalidate_webhook_headers) that resolves which webhooks reference a given KeyValue node and clears their cache entriesKeyValueGetWebhooksQuerytraverseswebhook__headersrelationships to find affected webhooksTRIGGER_KEYVALUE_WEBHOOK_INVALIDATEhas been added tocatalogue.pyHow to review
Since this PR is based on other PRs, commits to be reviewed start from Encapsulate raw strings into small detectable objects
backend/infrahub/webhook/query.py— Cypher query joining KeyValue → Relationship → Webhookbackend/infrahub/webhook/tasks/invalidate.py+cache.py— the Prefect flow and cache deletion taskbackend/infrahub/webhook/triggers.py— trigger definition for KeyValue eventsunit/webhook/test_invalidate.py,component/webhook/test_query.py,functional/webhook/test_invalidate.pyHow to test
Impact & rollout
Checklist