Billing integration dedup credits & stalling fixes #12796
Merged
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.


Proposed commit message
This fixes multiple bugs, while slightly changing the collection behavior for credits data.
The wrong credit computation was caused by the lack of deduplication. This is fixed by ensuring we only look at the last 24h, and controlling the IDs within 24h (edge case with multiple collecting agents, or agent full reinstall).
The stalling collection was caused by a missing
api_keycarry-over when an error is faced. As a nice benefit, i've also ensured that an error while back-feeding doesn't completely stops the collection, ie the agent will attempt to move forward until "live" in spite of the error(s).TODOs
organization_id/daily timestamp/ecu_quantity/start(assuming we never have 2 orders on the same date with the exact amount of ECUs)want_moreis true (reference)Stalling collection fix
The integration will now return "empty" documents if no cost is returned for the point of collection. This ensures the
want_morebehavior is enforced.