Skip to content

[usage] Decouple billing controller from usage controller #10785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tracked by #9036
easyCZ opened this issue Jun 21, 2022 · 2 comments
Closed
Tracked by #9036

[usage] Decouple billing controller from usage controller #10785

easyCZ opened this issue Jun 21, 2022 · 2 comments
Assignees
Labels
team: webapp Issue belongs to the WebApp team

Comments

@easyCZ
Copy link
Member

easyCZ commented Jun 21, 2022

Fix up how we trigger the sending of the usage report into Stripe. Currently it's done inside the ReconcileTimeRange This currently causes tests to report
[ERROR] Request error from Stripe (status 401): {"status":401,"message":"You did not provide an API key.
What we want is something akin to a pipeline.
Generate the report and return it. This completes the usage controller "data munching"
(later) Store it.
Pass it onto a Billing Controller.
In practice, it should be possible to succeed the usage report, but fail the Stripe update (for example for Stripe outage reasons)

@easyCZ easyCZ added the team: webapp Issue belongs to the WebApp team label Jun 21, 2022
@easyCZ easyCZ mentioned this issue Jun 21, 2022
73 tasks
@easyCZ
Copy link
Member Author

easyCZ commented Jul 26, 2022

Investigating this further, the easiest seems to actually introduce the following Services and RPCs:

  1. UsageService.CollectUsage()
  2. BillingService.UpdateInvoices()
    These two are then responsible for performing the respective parts of the control loops, can be invoked remotely but in the common case, are invoked periodically by the cron in the controller.

Doing so also gives us a couple of benefits:

  1. Improved observability of either task, as we can piggy back on gRPC observability
  2. When we need to sync explicitly, we can do so over an RPC
  3. Makes it possible to in the future decouple the RPC trigger from the implementation - k8s cron

How would this actually look like?

@easyCZ
Copy link
Member Author

easyCZ commented Aug 2, 2022

This is now complete.

@easyCZ easyCZ closed this as completed Aug 2, 2022
@easyCZ easyCZ moved this to Done in 🍎 WebApp Team Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team: webapp Issue belongs to the WebApp team
Projects
Archived in project
Development

No branches or pull requests

1 participant